Solved

Switch

Posted on 2013-06-10
9
361 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 500 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
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!

 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
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 500 total points
ID: 39234700
As I mentioned, don't include the quotes. It's just True,
0
 
LVL 92

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 92

Expert Comment

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

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
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…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

749 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