How to use 3 criterias in filtering a report using VB (1 Viewer)

irslan rafique

Registered User.
Local time
Today, 19:56
Joined
Oct 17, 2014
Messages
26
Hi,
My report(Invoice) is based on a query.
I am filtering report(on a filed 'DriversName') using following command:

DoCmd.OpenReport "Invoice", acViewPreview, , "DriversName like '*" & txtname & "*'"(working fine)

Can anybody tell me please that how to use 3 criteria or two more filters in same command.

1st Criteria: DriversName (Text)
2nd Criteria: Month (Text)
3rd Criteria: Year (Number)

Your early and prompt help will be highly appreciated.

Thanks in advance
 

CJ_London

Super Moderator
Staff member
Local time
Today, 12:56
Joined
Feb 19, 2013
Messages
16,723
Please do not double post - other thread here

http://www.access-programmers.co.uk/forums/showthread.php?t=273743

In answer to your question you use AND or OR depending on requirements

DoCmd.OpenReport "Invoice", acViewPreview, , "DriversName like '*" & txtname & "*' AND myMonth='" & txtMonth & "' AND myYear=" & txtYear

Note that month and year are reserved words and using them as field or table names can have unintended consequences
 

Users who are viewing this thread

Top Bottom