Using a wildcard character in Select Case

  • Thread starter Thread starter Rose
  • Start date Start date
R

Rose

Can this be done? I have a certain company that has many
locations, and the location is at the tail end of the name.
I need to find all companies that begin with the word
"Budget" for one of my select case statements. "Budget*" or
"Budget"* doesn't work.

The statement, FYI, is:
Case "Budget*", "OPSM", "Precision"
isGroup = "OPSM"
 
Rose,

This is not possible with the select-case construct, but you could use an if
statement:

If company Like "Budget*" Then
 
Crap. I need to use Select because I actually have about 15
companies I'm herding off to their own particular groups,
and that's too long for an If. (I only quoted part of the
whole function in my example.)

Are my only other solutions to either change my data, run
another layer of query to effectively change my data, or
have an incredibly long (and regularly updated) Select
statement?
 
You can specify a range in a Case.

Since the wildcard is the trailing character, this should work:

Case "Budget" to "Budgetzzzzzzzzz", "OPSM", "Precision"
 
Rose,

Can you provide all of your examples I am not sure I follow exactly what you
want to do?
For instance you stated that the location name is always at the end of the
company name so why not look at it from that prespective and combine it with
your select case statement for instance:

If companyname LIKE "*OPSM" Then
IsGroup = "OPSM"
Else If companyName Like "*XXX" Then
IsGroup = "XXX"
Else If ...

Else
Select Case companyName
Case "Percision"
Case ...
End Select
End If

You could as you suggested create another table that relates the company to
a group such as:

CompanyID, GroupID


Regards,
Dan
 
Perfect - thanks!!
-----Original Message-----
You can specify a range in a Case.

Since the wildcard is the trailing character, this should work:

Case "Budget" to "Budgetzzzzzzzzz", "OPSM", "Precision"

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.
 
Back
Top