Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Switch

Posted on 2013-06-10
9
Medium Priority
?
382 Views
Last Modified: 2013-06-10
Experts,

I get an error of Wrong Number of Arguments.  Do you see where the error is?  
The below use to be an IIF (that worked fine) but I switched it to a "SWITCH" because I needed to add another condition.  I imagine it is a syntax somewhere.  thank you.

MyGroup: Switch(([tblStatus.Status] Like "*Awarded*" Or [tblStatus.Status] Like "Won*" Or IsNull([ContractAward])=False,"Awarded - within last 60 days", [ATTApprvDate] Is Not Null and [ContractAward] is Null, "Went to ATT but not Awarded", GetGroup([Projects.BidCloseDate],[Projects.ATTApprvDate],[Projects.ATCApprvDate],[Projects.ATSApprvDate],[Projects.ContractAward],[Projects.CorpATTDate],[Projects.ExpectedContractAward])))
0
Comment
Question by:pdvsa
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39234597
If GetGroup returns a True/False response then you're missing the argument after it if the response is True.  If GetGroup returns a response other than True/False, this needs to be dealt with first.
0
 
LVL 29

Accepted Solution

by:
IrogSinta earned 2000 total points
ID: 39234614
Wait a minute, did you want to return the result of GetGroup if neither of the first 2 criteria wetter met?  If so, then add "TRUE," (without the quotes) right before GetGroup.
0
 

Author Comment

by:pdvsa
ID: 39234685
I added the TRUE and I dont have any errors.  BUT it doesnt want to save it?  


I Have it as follows: (only difference from initial post is the "True" (in bold) and when I tab out it doesnt give any errors and I close and save but when I open again it reverts back to the original.
Strange. Any idea why it it wont save as below?

MyGroup: Switch(([tblStatus.Status] Like "*Awarded*" Or [tblStatus.Status] Like "Won*" Or IsNull([ContractAward])=False,"Awarded - within last 60 days", [ATTApprvDate] Is Not Null and [ContractAward] is Null, "Went to ATT but not Awarded","True", GetGroup([Projects.BidCloseDate],[Projects.ATTApprvDate],[Projects.ATCApprvDate],[Projects.ATSApprvDate],[Projects.ContractAward],[Projects.CorpATTDate],[Projects.ExpectedContractAward])))
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 49

Expert Comment

by:Dale Fye
ID: 39234693
1. Too many parenthesis.

2.  When wrapping [table.field] in brackets, each should have its own opening and closing brackets [table].[field]

3.  As IrogSinta indicates, you must have an even number of parameters.  Your call to GetGroup must either return a True/False value or be evaluated against some other value to get a True/False.  Then you need to return a return value for the Switch statement for that element.

4.  I always (while debugging a Switch statement) include a final pair of parameters  (True, "No Match") in my Switch statements so that I can identify records that don't meet any of the parameters provided.  

Switch([tblStatus.Status] Like "*Awarded*" Or [tblStatus.Status] Like "Won*" Or IsNull([ContractAward])=False,"Awarded - within last 60 days",
[ATTApprvDate] Is Not Null and [ContractAward] is Null, "Went to ATT but not Awarded", GetGroup([Projects].[BidCloseDate],[Projects].[ATTApprvDate],[Projects].[ATCApprvDate],[Projects].[ATSApprvDate],[Projects].[ContractAward],[Projects.CorpATTDate],[Projects.ExpectedContractAward]), "Get Group", True, "No Match")
0
 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 2000 total points
ID: 39234700
As I mentioned, don't include the quotes. It's just True,
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 39234703
If you need a refresher on how to use the Switch function, please have a look at my article here.

I think Ron has nailed the reason you are getting that error: You have an odd number of arguments in your Switch expression, which is a no-no.  If your intent is, "if all else fails, then return the value from the GetGroup() expression", then Ron is correct that you need to preface that with an expression that is always true:

MyGroup: Switch([tblStatus.Status] Like "*Awarded*" Or [tblStatus.Status] Like "Won*" Or [ContractAward] Is Not Null,"Awarded - within last 60 days", [ATTApprvDate] Is Not Null And [ContractAward] is Null, "Went to ATT but not Awarded", True, GetGroup([Projects.BidCloseDate],[Projects.ATTApprvDate],[Projects.ATCApprvDate],[Projects.ATSApprvDate],[Projects.ContractAward],[Projects.CorpATTDate],[Projects.ExpectedContractAward]))

Open in new window


Note that while the simple boolean value True is sufficient, you can also do things like 1=1.  I address this "none of the above" option in my article.
0
 

Author Closing Comment

by:pdvsa
ID: 39234752
thank you.  Fyed:  it said I have a criteria mismatch error (or something like that)... OK thanks guys....gotta run...
0
 
LVL 29

Expert Comment

by:IrogSinta
ID: 39234985
That's a pretty good article, Matthew. Very extensive.
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 39235302
Thanks for the compliment, Ron :)
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question