Solved

Switch

Posted on 2013-06-10
9
317 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
Comment Utility
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
Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

 
LVL 29

Assisted Solution

by:IrogSinta
IrogSinta earned 500 total points
Comment Utility
As I mentioned, don't include the quotes. It's just True,
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
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
Comment Utility
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
Comment Utility
That's a pretty good article, Matthew. Very extensive.
0
 
LVL 92

Expert Comment

by:Patrick Matthews
Comment Utility
Thanks for the compliment, Ron :)
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

771 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now