Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Array Variables In Select Case 1

Status
Not open for further replies.

SgtJarrow

Programmer
Apr 12, 2002
2,937
US
I have a simple concept. I want to use a varable as a case statement. Before I begin development, just looking to know if it is even possible.

Here's the situation...Access 2K....Set of business rules. The rules define which process path to take for each record depending on the last two digits of the identifier field. For example:

Select Case Right([IdField], 2)
Case "01", "02", "11", "12"
Do This
Case "15", "16", "25", "26"
Do That
End Select

The numbers assigned to each process may change...but the number of processes will not...There are only three paths. What i want to do is give the users two tables, one for each path, and allow them to update the numbers. The code will fill an array and be available for the Case statements.

Can this be done? If you have done something similar before, and want to share me some code, I'll gladly accept it...but I already have code for filling an array from a table and all the other code is up and running when I hard code the numbers....just want to make this dynamic so the users aren't calling me to change the rules all the time...

Thanks... Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
You mean, like,
Code:
    Case array1
        DoThis
    Case array2
        DoThat
Is that what you mean? Can't do it.

But the code that reads the tables can simply compare Right([IdField], 2) to each entry, and take appropriate action depending on which table the match is found in. Or, you could go ahead and build the arrays but use two For...Next loops to determine which table the match is in. There are probably one or two other variations as well. You just can't do it with a Case statement. Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Hi

Do you mean:

Select Case Right([IdField], 2)
Case IN strList1
Do This
Case IN List2
Do That
End Select

Where List1 and list2 are strings of two digit pairs, equivalent to your hard coded example?

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
RickSpr and KenReay,

Thanks for your input. It is as I expected....I am going to go with the For...Next loops for evulation...

I'll get it working....was just hoping for a simple case statement solution. Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. (Albert Einstein)

Robert L. Johnson III, MCP, Network+, A+
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top