Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 313
  • Last Modified:

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,"")
0
pdvsa
Asked:
pdvsa
  • 6
  • 4
2 Solutions
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Maybe this - and seems you are missing the Switch word itself ...?

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???")
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Also, keep in mind that Switch is limited to 15 pairs I believe ...

mx
0
 
Patrick MatthewsCommented:
I can confirm, once you actually include the function name in your expression, it works.

Please note that in the condition:

[Acivity Code] Like "MS *"

you seem to have misspelled 'Activity'.  If you do not fix that, Access will prompt you for parameter input :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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,"")
0
 
Patrick MatthewsCommented:
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:

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

Patrick
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Yes ... I know that :-)

same as   1-1, <SomeDefaultValue>

mx
0
 
Patrick MatthewsCommented:
Think you mean 1 = 1

:)
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
Yep ... NOT enough coffee yet ... and working on songs for a gig tomorrow night!
0
 
Patrick MatthewsCommented:
Be sure to post on Facebook how the show goes.  I for one am interested :)
0
 
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)Commented:
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
0
 
pdvsaProject financeAuthor Commented:
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.
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 6
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now