Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Switch

Experts:  it says I have a syn tax in this Swtich:  
(it could be towards the end with the True part.  

MyBusUnit: ([Activity Code] Like "DH*","Onshore Houston",[Activity Code] Like "LA*","Onshore Claremont",[Activity Code] Like "GS *","Subsea",[Activity Code] Like "ES *","Engineering Offshore",[Activity Code] Like "KT*","KTI",[Acivity Code] Like "MS *","Overhead Charges",[Activity Code] Like "TFP *","Offshore Fixed Platform",[Activity Code] Like "*TOF *","Offshore Finland",[Activity Code] Like "MX *","Onshore Mexico",[Activity Code] Like "DI *","What is DI???",True,"")
ASKER CERTIFIED SOLUTION
Avatar of DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
DatabaseMX (Joe Anderson - Former Microsoft Access MVP)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, keep in mind that Switch is limited to 15 pairs I believe ...

mx
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, please not that I am not associated with Offshore Mexico :-)

I did drop off your last condition, which I put back in Bold below ... wasn't sure you really wanted that.

MyBusUnit: Switch([Activity Code] Like "DH*", "Onshore Houston", [Activity Code] Like "LA*", "Onshore Claremont", [Activity Code] Like "GS *", "Subsea", [Activity Code] Like "ES *", "Engineering Offshore", [Activity Code] Like "KT*", "KTI", [Acivity Code] Like "MS *", "Overhead Charges", [Activity Code] Like "TFP *", "Offshore Fixed Platform", [Activity Code] Like "*TOF *", "Offshore Finland", [Activity Code] Like "MX *", "Onshore Mexico", [Activity Code] Like "DI *", "What is DI???" ,True,"")
MX,

Having a final pairing of:

MyField: Switch(..., True, "Something")

Open in new window


is basically enabling a return value for "none of the above".  It would be equivalent to excluding it, but then wrapping the Switch expression in Nz.  I explain its usage here:

https://www.experts-exchange.com/Microsoft/Development/MS_Access/A_3556-Using-the-Switch-Function-in-Microsoft-Access.html

Patrick
Yes ... I know that :-)

same as   1-1, <SomeDefaultValue>

mx
Think you mean 1 = 1

:)
Yep ... NOT enough coffee yet ... and working on songs for a gig tomorrow night!
Be sure to post on Facebook how the show goes.  I for one am interested :)
s/b packed ... but sadly, due to politics and club owner bs, this will apparently be the last show, as well as the weekly sunday night pro jam :-(

mx
Avatar of pdvsa

ASKER

I did forget the word SWITCH.  I copied it from a formula I had in word and I forgot to include it.  

I did mispell Activity also.