Filter in Form via VBA Code

  • Thread starter Thread starter TC
  • Start date Start date
T

TC

The button's Click event should say something like:

me.filter = me![xxx]
me.filteron = true

where xxx is the name of your combo box control.

HTH,
TC
 
Hi - Very urgent

I have a problem concerning a filter
The form default view is contious form
Now I want to apply a filter via click on a button.
The filter criteria should be based on a combobox in which I impor
values

CAN ANYONE HELP ?

What is the code I have to use
 
I used the following code !! The only problem I have is, that this cod
is applied to a subform. When I open the subform and run the code i
works
As soon as I open the mainform and try to run it in there it does no
work anymore.

Can anyone help

Private Sub Command135_Click()


Dim szLastName As String, szCrit As String

''' Retrieve user entered search criteria
Me.Combo136.SetFocus
szLastName = Me.Combo136.Text

''' Determine if user entered criteria
If Len(szLastName) < 1 Then
MsgBox "You must first enter a last name to search on."
Cancel = True
Else
''' Build criteria
Me.MBS_Nr.SetFocus

szCrit = BuildCriteria(MBS_Nr, dbText, szLastName)

''' Apply the filter to the form
DoCmd.ApplyFilter , szCrit
End If
End Su
 
Back
Top