Re: Compact Syntax for OR Condition
- From: "Dirk Goldgar" <dg@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 26 Jul 2007 09:35:35 -0400
In news:C17C5011-EA12-42AD-9221-5AE9B7BB853A@xxxxxxxxxxxxx,
DevDaniel <DevDaniel@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I have: a long list of OR conditions
e.g., var = apples OR var = bananas OR var = oranges
Is there a compact way of expressing this, like in SQL
e.g., var In (apples, bananas, oranges)
In VBA there's no "In" operator, unfortunately. A Select statement
might be somewhat more compact than a long list of "Or"s:
Select Case var
Case apples, bananas, oranges
' do something
End Select
Or you could use an InStr expression like this:
If InStr("/" & var & "/", "/apples/bananas/oranges/") > 0 Then
In such an expression, you have to choose a delimiter ("/" in the
example above) that doesn't occur in any of the values to be checked.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
.
- Follow-Ups:
- Re: Compact Syntax for OR Condition
- From: Douglas J. Steele
- Re: Compact Syntax for OR Condition
- Prev by Date: Choose Function
- Next by Date: Re: Closing Running Processes
- Previous by thread: Choose Function
- Next by thread: Re: Compact Syntax for OR Condition
- Index(es):
Relevant Pages
|