vbams-accessms-access-reports

Use multiple criteria on Reports


I have the following code which does not work:

DoCmd.OpenReport "rptHome", acViewPreview, , "Room LIKE '*" & Room.Value & "*'" And "Flat LIKE '*" & Flat.Value & "*'"

I expect the report to include the records with Room and Flat only.

However, the code works fine when used like below:

DoCmd.OpenReport "rptHome", acViewPreview, , "Room LIKE '*" & Room.Value 
& "*'"

Is it possible to add another criteria as in my first attempt?


Solution

  • the keyword 'AND' must but included in the condition

    DoCmd.OpenReport "rptHome", acViewPreview, , "Room LIKE '*" & Room.Value & "*' AND Flat LIKE '*" & Flat.Value & "*'`