Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applying filters and criteria using delimeters and fields

Status
Not open for further replies.

Knicks

Technical User
Apr 1, 2002
383
US
Access2000

I am trying to create a multiple field filter using vba. I would like to include the Like * on the front end of the 2nd and 3rd criteria so that if a user does not include an option for field 2 or field 3 the filter will show all results for field 1

Here is what I have that works so far. Where supplier is a number.

DoCmd.ApplyFilter "", "[supplier] = " & Me.[Combo95]


I get into trouble when I try to add another field to the string like this. I think I need an ampersand and probably some more quotes but I can't figure out where. I would also like to include a Like "*" in front of
Code:
 if possible. [code] is also a numeric field. I can only imagine how complicated this would be if it was text! Any help would be greatly appreciated.


DoCmd.ApplyFilter "", "[supplier] = " & Me.[Combo95]_
And & "code = " & Me.[combo98]
 
DoCmd.ApplyFilter "", "[supplier] = " & Me.[Combo95] & "And
Code:
 = " & Me.[combo98]
?
something like
 
Dim strSQL As String

strSQL = "supplier = "&Me!Combo95 And _
&"code = "&Me!combo98

DoCmd.ApplyFilter where condition := strSQL

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top