<< Click to Display Table of Contents >> Navigation: Apollo API Listing > sx_FilterAlias |
Declare Function sx_FilterAlias Lib "Apollo9.dll"
(ByVal cpAliasName As String,
ByVal cpFieldName As String)
As Integer
BOOL FAR PASCAL sx_FilterAlias
(BYTEP cpAliasName,
BYTEP cpFieldName);
Assigns an alias name to a field name in the table to be used in an upcoming sx_FilterDlg call. If an alias list is created with this function, only those fields defined with an alias will be shown in the sx_FilterDlg Fields List Box, and the Fields List Box will refer to a field by its alias name first.
sx_FilterDlg creates a filter builder dialog box that allows your users to construct filter expressions that apply to the current table. The use of alias field names allows the applications programmer to redefine cryptic table field names with a moniker that the casual user might understand.
To create a list of alias/field names, call this function repeatedly for each field you wish to display in the sx_FilterDlg Fields List Box.
cpAliasName: The alternate field name. Maximum length is 15 characters.
cpFieldName: The actual field name.
True if the field was found. False if an error was encountered.
Note: The list of alias names is automatically destroyed after calling sx_FilterDlg.
' User filter setting
Sub bFilter_Click ()
Dim lRecNum As Long
Dim cString As String
Dim iRet As Integer
If Not FilterOn Then
' set up alias names
iRet = sx_FilterAlias("LastName", "last")
iRet = sx_FilterAlias("FirstName", "first")
iRet = sx_FilterAlias("Address", "a1")
iRet = sx_FilterAlias("City", "a2")
iRet = sx_FilterAlias("State", "a3")
' allow User to set the query by passing
' iIsIndexList as TRUE
cString = sx_FilterDlg(sxtest.hWnd, 0&, "My App Name", TRUE)
If Len(cString) > 0 Then
FilterOn = True
End If
If FilterOn Then
bFilter.Caption = "&Reset"
End If
Else
' clear query
FilterOn = False
bFilter.Caption = "&Filter"
lRecNum = sx_Query(0&)
End If
End Sub
void CNamesForm::OnButtonFilter()
{
sx_FilterAlias("LastName", "last");
sx_FilterAlias("FirstName", "first");
sx_FilterAlias("Address", "a1");
sx_FilterAlias("City", "a2");
sx_FilterAlias("State", "a3");
sx_FilterDlg(GetParent(), NULL, NULL, FALSE));
// test if user set filter
if (lstrlen(sx_DBFilter()))
bFilterOn = TRUE;
...
...
}