Wild card

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using an If Then statment and trying to include a couple of choices using
or as a separation.

If Me.Request.Value = "Legal - Ordinance (Modify)" Or "Legal - Open Records"
Or "Legal - Ordinance (Other)" Then

However, it only works if I repeat the Me.Request.Value for each possible
selection.

If Me.Request.Value = "Legal - Ordinance (Modify)" Or Me.Request.Value =
"Legal - Open Records" Or Me.Request.Value = "Legal - Ordinance (Other)" Then

Is there a way to shorten this and use a wildcard selecting request that
starts with Legal?
 
I'm using an If Then statment and trying to include a couple of choices using
or as a separation.

If Me.Request.Value = "Legal - Ordinance (Modify)" Or "Legal - Open Records"
Or "Legal - Ordinance (Other)" Then

However, it only works if I repeat the Me.Request.Value for each possible
selection.

If Me.Request.Value = "Legal - Ordinance (Modify)" Or Me.Request.Value =
"Legal - Open Records" Or Me.Request.Value = "Legal - Ordinance (Other)" Then

Is there a way to shorten this and use a wildcard selecting request that
starts with Legal?

As you discovered, the correct syntax is for each operand to be a
complete expression.

You should be able to use Me.Request, dropping the .Value.

At least break it onto three lines for readability, using the line
continuation character. I usually do it like this:

If Me.Request = "Legal - Ordinance (Modify)" _
Or Me.Request = "Legal - Open Records" _
Or Me.Request = "Legal - Ordinance (Other)" Then


Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
As you discovered, the correct syntax is for each operand to be a
complete expression.

You should be able to use Me.Request, dropping the .Value.

At least break it onto three lines for readability, using the line
continuation character. I usually do it like this:

If Me.Request = "Legal - Ordinance (Modify)" _
Or Me.Request = "Legal - Open Records" _
Or Me.Request = "Legal - Ordinance (Other)" Then


Armen Stein
Microsoft Access MVP
www.JStreetTech.com

Okay, I'll admit I didn't read the question fully on this one, missing
the "starts with" request at the end. Sorry about that.

However, upon further thought, I'm a little concerned that action will
be taken on the text value of a record. What if the records aren't
always spelled the same way? It would be much more precise to relate
these records to a lookup table, with one lookup record called Legal,
and then based the action on that.

Armen Stein
Microsoft Access MVP
www.JStreetTech.com
 
CORRECTION

you need to use the LIKE 'LEGAL%'


the asterisk is a depecrated notion
 
Wussernark
Since when does VBA support % as a wildcard? What version are you using.
 
Its Aaron the lonely troll, not Tom. Aaron's name is blocked in so many
places that he's started using others. His idea of a giggle, i guess.
 
George

Oh, I *KNOW* who it is. That's why I addressed him as "Wussernark". Too bad
someone who professes to know so much falls short so often in public.
 
Back
Top