Solved

#Error Conversions

Posted on 2014-10-28
6
156 Views
Last Modified: 2014-10-28
Experts,

I have an access query that we use for inspections and the value is a string. My problem lies is that 90% of the time my field data are numbers and I convert them to a double in another query column so we can perform calculations to that field i.e. CDbl[Result1]. My problem is I have it as a string because my customers require me to occasionally type "Pass" or "Fail" due to the fact that they are visual inspections and do not have a calculated result. So in my converted column I get the #Error for all the places it has a "Pass" or "Fail" results. Is there where away to create another column maybe using the IIf statement to convert the #Error back to the "Pass" or "Fail"? I tried this but the computer won't recognize the #Error as a value.

Actual 1: IIf([Convert 1]=#Error,[Result1],[Convert 1])

Any help is greatly appreciated.
0
Comment
Question by:NuclearOil
  • 3
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
PatHartman earned 500 total points
ID: 40408538
How would pass or fail be "counted" in the calculation?

I would probably go with two columns.  One for the value and one for the grade.  You can calculate the grade based on the value so grade can be required.  Value seems to need to be optional.

You can't check for #Error, you would need to prevent it by testing for a not numeric value prior to doing the calculation.

IIf(IsNumeric(SomeField), ...calc here..., SomeField) As Result

The expression above will result in a string so again, you will have trouble down the line if you need to sum or create an average.  Just go with two columns and stop the confusion.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40408544
Try:

Actual 1: IIf(iserror([Convert 1]),[Result1],[Convert 1])
0
 

Author Comment

by:NuclearOil
ID: 40408606
Pat,

I would like to go with two columns but I have too much data stored that way. The way it was set up, pre dates me. Is there a way to convert the "#Error" to just appear as nulls?
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

Author Comment

by:NuclearOil
ID: 40408610
Phillip,

Still comes up as #Error.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40408635
Then try:

IIf([Convert 1]="#Error",[Result1],[Convert 1])
0
 

Author Closing Comment

by:NuclearOil
ID: 40408639
Pat,

The is numeric function will get me buy for what i need to do.

Thank you!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

808 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