Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Switch

Posted on 2013-06-10
9
Medium Priority
?
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 48

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

609 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