By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
462,107 Members | 717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 462,107 IT Pros & Developers. It's quick & easy.

Switch Statement dynamic values?

Cintury
P: 81
This is my first time utilizing the switch statement and I was wondering if it was possible to return a dynamic value for any conditional expression of the statement. E.g. my values are based data from a table which varies depending on the record the switch is calling against.

Expand|Select|Wrap|Line Numbers
  1. Switch([Food_Category_ID] = 0, [tblFoodDonations]![Bakery], [Food_Category_ID] = 1, [tblFoodDonations]![Dairy],
  2. [Food_Category_ID] = 2, [tblFoodDonations]![Meat],
  3. [Food_Category_ID] = 3, [tblFoodDonations]![Fruit], 
  4. [Food_Category_ID] = 4, [tblFoodDonations]![Vegetable], 
  5. [Food_Category_ID] = 5, [tblFoodDonations]![Prepared],
  6. [Food_Category_ID] = 6, [tblFoodDonations]![Juice],
  7. [Food_Category_ID] = 7, [tblFoodDonations]![Non-Perishable], [Food_Category_ID] = 8, [tblFoodDonations]![Non-Food])
  8.  
I also utilize a dynamic value in the expression, not sure if thats also a problem?
Oct 1 '09 #1

✓ answered by NeoPa

Would Choose() not suit your purposes better?

PS. You don't say so, but I'm guessing this is within SQL code rather than VBA?

Share this Question
Share on Google+
2 Replies

NeoPa
Expert Mod 15k+
P: 31,770
Would Choose() not suit your purposes better?

PS. You don't say so, but I'm guessing this is within SQL code rather than VBA?
Oct 2 '09 #2

Cintury
P: 81
I tried it yesterday within sql for ms access and inside a vba module. Both gave me zeros as a value, I will try the choose() function and report my results.

Thanks
Oct 2 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.