[AccessD] need help with filter code

Rocky Smolin - Beach Access Software bchacc at san.rr.com
Tue Feb 17 08:53:06 CST 2004


Pedro:

I do something similar (I hope) with reports where the user can enter >=
and/or <= values on any of several fields to filter the contents of the
report.

Then I set up the filter like so:

strFilter = ""

If Nz(Forms!frmBuyReport!txtGEDescription) <> "" Then
    If strFilter <> "" Then strFilter = strFilter & " AND "
    strFilter = strFilter & "Description >= '" &
Nz(Forms!frmBuyReport!txtGEDescription) & "'"
End If

If Nz(Forms!frmBuyReport!txtLEDescription) <> "" Then
    If strFilter <> "" Then strFilter = strFilter & " AND "
    strFilter = strFilter & "Description <= '" &
Nz(Forms!frmBuyReport!txtLEDescription) & "'"
End If

If strFilter <> "" Then
    Me.Filter = strFilter
    Me.FilterOn = True
Else
    Me.Filter = ""
    Me.FilterOn = ""
End If

Of course you can substitute Like for >= and <=.  And OR for AND if you are
looking for A OR B OR C OR D vs A AND B AND C AND D.

HTH

Rocky Smolin
Beach Access Software

----- Original Message ----- 
From: "Pedro Janssen" <pedro at plex.nl>
To: <AccessD at databaseadvisors.com>
Sent: Tuesday, February 17, 2004 1:35 AM
Subject: [AccessD] need help with filter code


Hello Group,

i have 6 patients fields in which i want to do a search on their names.
I don't want to use the existing filter in access, but search with a
commandbutton and a textbox.
I can use the following code with 6 cmdbuttons and 6 textboxes,
but that doesn't work in practice.
What i want is one cmdbutton and one txtbox that searches true all 6 fields
Can you help me on this?


Private sub  cmdsearch1_Click()
Me.Filter = "qryPatientData.Patient1ID Like'*" & Me.txtboxSearch1 & "*'"
Me.FilterOn = True
Me.Requery
Me.Refresh

End Sub
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list