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

x
?
Solved

#error in switch function

Posted on 2014-01-09
6
Medium Priority
?
635 Views
Last Modified: 2014-01-29
Experts. I have a pretty complex query in our Access database. It displays the income guidelines for our apartment buildings. I used to use nested iif statements but there got to be too many different income limit percentages so I have to change my equations to the switch function.

Everything works/displays fine but we have 'previous year' buttons that display the limits from the past. When I click this button to go to a previous year and then close that screen to go back to the current year all my textboxes (which house the results from the switch function) turn to #error.

I have tried:
1. closing all these income limits screens and re-opening fresh thinking the same table is opening in both record sources and it doesn't like that but that didn't change anything.
2. also renamed text boxes on the screen to make sure they didn't match the actual field name. That didn't change anything.

I can attach the actual database if need be, it will just take some time. Please let me know if that would be helpful. Attached are some screen shots of the database and a text document with a snippet of the SQL.
before.jpg
after.jpg
switch.txt
0
Comment
Question by:acramer_dominium
[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
  • 3
  • 2
6 Comments
 
LVL 13

Expert Comment

by:Ashok
ID: 39768903
Switch evaluates all of the expressions, even though it returns only one of them. For this reason, you should watch for undesirable side effects. For example, if the evaluation of any expression results in a division by zero error, an error occurs.
0
 

Author Comment

by:acramer_dominium
ID: 39768934
Ok. That makes sense. There will be only one of those expression that returns a 'true'. Why does it work on the first viewing of the screen though and then error out after you open another screen and go back to it?
0
 
LVL 13

Expert Comment

by:Ashok
ID: 39768967
It looks like
data returned might be null (when it is not working) because I see error in all of them.

I do not have MS Access and not an expert.

Is there a way for you to run the application in the DEBUG mode?

then just before you try to get to the screen where error shows up, put a breakfront in the code (on the SWITCH statement).  Inspect values.

HTH
Ashok
0
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.

 

Author Comment

by:acramer_dominium
ID: 39769136
The SQL is all in a query there's no debugging that can be done. The data returned is not null there is a dollar amount that the statement returns.
0
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 1500 total points
ID: 39773087
Ashok is correct that Switch will evaluate all the expressions, and not just stop when it finds the first true condition.  For more about Switch: http://www.experts-exchange.com/Microsoft/Development/MS_Access/A_3556-Using-the-Switch-Function-in-Microsoft-Access.html

To really troubleshoot this we will need a copy of the DB.
0
 

Author Closing Comment

by:acramer_dominium
ID: 39818078
Looking for another alternative
0

Featured Post

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.

Question has a verified solution.

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

Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
With its various features, Office 365 can not only help you with your day-to-day business tasks, it can also do wonders for your marketing campaign.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 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