OpnReport with multiple conditions

  • Thread starter Thread starter Guest
  • Start date Start date
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'"
 
DoCmd.OpenReport "F/U: Complete Report -- Finaltest", acViewPreview, ,
WhereCondition:="[AdvisorLang]='PrintLang' And [MailCode]='PrintDist'"
 
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'"
 
Back
Top