Re: Using 'OR' for criteria

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Sandra Daigle (Invalid_at_KeepYourSpam.org)
Date: 10/13/04


Date: Wed, 13 Oct 2004 11:21:50 -0400

Hi Paul,

No problem - glad you got it solved (and you figured out the embedded
quotes by yourself :-))!

-- 
Sandra Daigle [Microsoft Access MVP]
Please post all replies to the newsgroup.
Paul B. wrote:
> Hi Sandra,
>
> Ignore the last part, stupid 'new guy' mistake, I had not removed the
> code from the previous attempt at creating the command button.
>
> So now I actually have it working, it looks like this:
>
> DoCmd.OpenForm stDocName, , , "[VehLocation]=" & "'242' OR
> [VehLocation]=" & "'243'"
>
> Thanks for pointing me in the right direction.....
>
> Cheers
>
> "Sandra Daigle" wrote:
>
>> Hi Paul,
>>
>> Please post your code - I'm not sure what might be causing that
>> error. Also, please indicate which line is highlighted when the
>> error occurs when you go into debug mode.
>>
>> One other thing, does the code compile?
>>
>> --
>> Sandra Daigle [Microsoft Access MVP]
>> Please post all replies to the newsgroup.
>>
>>
>> Paul B. wrote:
>>> Thanks for the help with the IN ( ) criteria. I had not come accross
>>> that one yet.
>>>
>>> However, now I am getting an error, when I click on the button to
>>> search, I get 'The OpenForm action was canceled' . If I take out the
>>> criteria, the form opens and shows all records, but using both of
>>> your suggestions, generates the same error. The code is exactly as
>>> you suggested, double checked in case my fat thumbs got in the
>>> way....
>>>
>>>
>>>
>>> "Sandra Daigle" wrote:
>>>
>>>> Are you opening this form from another form using the
>>>> WhereCondition parameter? You would either build a complex
>>>> criteria statement or use the In() criteria. Examples of both are
>>>> shown below:
>>>>
>>>> DoCmd.OpenForm "frmVehicles", , , "VehLocation=241 or
>>>> VehLocation=242 or VehLocation=244 or  VehLocation=261 or
>>>> VehLocation=262"
>>>> DoCmd.OpenForm "frmVehicles", , , "Vehlocation
>>>> in(241,242,244,261,262)"
>>>>
>>>> The above examples use hardcoded lists of values, typically you
>>>> would be getting the test values from a listbox or some other way.
>>>> Postback if you need help with this.
>>>>
>>>> --
>>>> Sandra Daigle [Microsoft Access MVP]
>>>> Please post all replies to the newsgroup.
>>>>
>>>>
>>>> Paul B. wrote:
>>>>> Can someone advise how best to create a link criteria that would
>>>>> allow a form to display records that match several criteria?
>>>>>
>>>>> I want to search my tblVehicles for VehLocation that match a
>>>>> numeric value of 241 or 242 or 244 or 261 or 262.
>>>>>
>>>>> Thanks in advance 

Quantcast