C
Charles D Clayton Jr
I have a dbs in A2K that I need to make easier for the user to use.
To that end I have created command buttons for sorting. I have the
code for an Ascending and descending, by selection and exclude
selection and removing all filters. However, what I cannot figure out
is the "Filter for" option. When I right click in a datasheet (which
is the way the subform is set up) I get an option to "filter for" and
then I type whatever I needed. It is nice because you can use
wildcards. The code that I am using is this for my sorting buttons is
this (the example is sorting A to Z)
Private Sub cboSortAZ_Click()
On Error GoTo cboSortAZ_Error
Dim cntl As Control
Set cntl = Screen.PreviousControl
cntl.SetFocus
DoCmd.RunCommand acCmdSortAscending
Exit Sub
cboSortAZ_Error:
If Err.Number = 2046 Then
'Not available at this time
MsgBox "Put cursor in field to sort by!"
Else
MsgBox Err.Number & ": " & Err.Description
End If
End Sub
I have looked through the help file and the closest I could find was
the acCmdApplyFilterSort but I could never get it to work (if, in
fact, it is what I need). I have multiple columns that the user could
pick to do a search in so I do not quite know how to trap that
information easily. Before I could use the PreviousControl but know I
do not know.
Does anybody have any suggestions?
Thanks,
Charles D Clayton Jr
To that end I have created command buttons for sorting. I have the
code for an Ascending and descending, by selection and exclude
selection and removing all filters. However, what I cannot figure out
is the "Filter for" option. When I right click in a datasheet (which
is the way the subform is set up) I get an option to "filter for" and
then I type whatever I needed. It is nice because you can use
wildcards. The code that I am using is this for my sorting buttons is
this (the example is sorting A to Z)
Private Sub cboSortAZ_Click()
On Error GoTo cboSortAZ_Error
Dim cntl As Control
Set cntl = Screen.PreviousControl
cntl.SetFocus
DoCmd.RunCommand acCmdSortAscending
Exit Sub
cboSortAZ_Error:
If Err.Number = 2046 Then
'Not available at this time
MsgBox "Put cursor in field to sort by!"
Else
MsgBox Err.Number & ": " & Err.Description
End If
End Sub
I have looked through the help file and the closest I could find was
the acCmdApplyFilterSort but I could never get it to work (if, in
fact, it is what I need). I have multiple columns that the user could
pick to do a search in so I do not quite know how to trap that
information easily. Before I could use the PreviousControl but know I
do not know.
Does anybody have any suggestions?
Thanks,
Charles D Clayton Jr