Filter Syntax with OpenReport

Robert Burns

Registered User.
Local time
Today, 09:51
Joined
Jul 1, 2002
Messages
14
Hi there,

I am having trouble due to my lack of syntax knowledge regarding the 'wherecondition' part of the DoCmd.OpenReport command. I am opening a report from various command buttons on a form and applying different filter criterias. This works fine when filtering on a field being equal to one value, as in:

strFilter = "Claims = 'None' "
DoCmd.OpenReport "rptFiltered", acViewPreview,,strFilter

but doesn't work when filtering on a field equal to one of two values, as in:

strFilter = "Claims = 'Settled' Or 'Both' "
DoCmd.OpenReport "rptFiltered", acViewPreview,,strFilter

Can someone help me with the correct syntax please.

Thanks very much,
Rob.
 
Rob, you were pretty close, try this...

strFilter = "[Claims] = 'Settled' Or [Claims] = 'Both' "

Always use brackets around fields, if not for any other reason than to avoid confusion. Anytime you use multiple criterian in code or in this case filters, you will need to restate the field.


Have fun.
 
Thanks very much Chenn,

I had tried many different combinations, but not that one!

Cheers,
Rob.
 

Users who are viewing this thread

Back
Top Bottom