OpnReport with multiple conditions

G

Guest

I am attempting to create multiple conditions when opening an access report
but with conditions based on different fields:

This is my existing code but I keep receiving an error; I believe it
pertains to incorrect syntax:

DoCmd.OpenReport "F/U: Complete Report -- Finaltest", acViewPreview, ,
WhereCondition:="[AdvisorLang]=PrintLang" And "[MailCode]='PrintDist'"
 
D

Douglas J. Steele

DoCmd.OpenReport "F/U: Complete Report -- Finaltest", acViewPreview, ,
WhereCondition:="[AdvisorLang]='PrintLang' And [MailCode]='PrintDist'"
 
G

George Nicholson

the WhereCondition argument expects a single string. "And" needs to be
inside the quotes, not outside.
WhereCondition:="[AdvisorLang]=PrintLang And [MailCode]='PrintDist'"

If either PrintLang or PrintDist are variables, you need to get them outside
the quotes for them to be evaluated before WhereCondition is passed:
WhereCondition:="[AdvisorLang]=" & PrintLang & " And [MailCode]='" &
PrintDist & "'"
(note the space before the A in And):

HTH,


Eric_G said:
I am attempting to create multiple conditions when opening an access report
but with conditions based on different fields:

This is my existing code but I keep receiving an error; I believe it
pertains to incorrect syntax:

DoCmd.OpenReport "F/U: Complete Report -- Finaltest", acViewPreview, ,
WhereCondition:="[AdvisorLang]=PrintLang" And "[MailCode]='PrintDist'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top