473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Change #Num! error in a report in access 2010

I have a calculated query that I have used for a report. These reports are generated for different departments, but some departments don't require the same fields. Consequently, sometimes the #Num! symbol comes up because that departments requirements are 0, thus it you can't divide 0/0. Is there a way to change the field value in the report to a 1 when that occurs?

iif([field]="#Num!", 1, [field]) but that didn't work?
Jan 15 '13 #1
4 3325
TheSmileyCoder
2,322 Expert Mod 2GB
I would probably modify the query instead. Could you post the SQL for the query please?
Jan 15 '13 #2
NeoPa
32,556 Expert Mod 16PB
If you are ever dividing by a variable that can resolve to zero (0) then the basic trick is to test it before the division (and only ever process the division when the divisor - or number to be divided by - is other than zero). Checking the result after the code crashing is very little help.

In a query (SQL) you would use something like :
Expand|Select|Wrap|Line Numbers
  1. IIf([Y] = 0, 1, [X] / [Y])
NB. Please remember to include all relevant information in your question post in future. Asking a query (SQL) question without including the SQL is generally unhelpful.
Jan 15 '13 #3
Query is below. As you can see not every department requires the same information; hence it is difficult to modify the query.
Expand|Select|Wrap|Line Numbers
  1. SELECT [Unit HSE Statistics].[Date:]
  2.      , ([unit hse statistics].[jsa]/[kpi targets by date and unit].[jsa]) AS JSA
  3.      , ([unit hse statistics].[cold work permit]/[kpi targets by date and unit].[cold work permit]) AS [Cold Work Permit]
  4.      , ([unit hse statistics].[hot work permit]/[kpi targets by date and unit].[hot work permit]) AS [Hot Work Permit]
  5.      , ([unit hse statistics].[man rider permit]/[kpi targets by date and unit].[man rider permit]) AS [Man Rider Permit]
  6.      , ([unit hse statistics].[live circut permit]/[kpi targets by date and unit].[live circut permit]) AS [Live Circut Permit]
  7.      , ([unit hse statistics].[confined space permit]/[kpi targets by date and unit].[confined space permit]) AS [Confined Space Permit]
  8.      , ([unit hse statistics].[radioactive permit]/[kpi targets by date and unit].[radioactive permit]) AS [Radioactive Permit]
  9.      , ([unit hse statistics].[diesel transfer permit]/[kpi targets by date and unit].[diesel transfer permit]) AS [Diesel Transfer Permit]
  10.      , ([unit hse statistics].[gas tests performed]/[kpi targets by date and unit].[gas tests performed]) AS [Gas Tests Performed]
  11.      , ([unit hse statistics].[loto performed]/[kpi targets by date and unit].[loto performed]) AS [LOTO Performed]
  12.      , ([unit hse statistics].[pre job meeting]/[kpi targets by date and unit].[pre job meeting]) AS [Pre Job Meeting]
  13.      , ([unit hse statistics].[pre tour meetings]/[kpi targets by date and unit].[pre tour meetings]) AS [Pre Tour Meetings]
  14.      , ([unit hse statistics].[weekly hse meetings]/[kpi targets by date and unit].[weekly hse meetings]) AS [Weekly HSE Meetings]
  15.      , ([unit hse statistics].[monthly hse meetings]/[kpi targets by date and unit].[monthly hse meetings]) AS [Monthly HSE Meetings]
  16.      , ([unit hse statistics].[safety committee meetings]/[kpi targets by date and unit].[safety committee meetings]) AS [Safety Committee Meetings]
  17.      , ([unit hse statistics].[supervisors meeting]/[kpi targets by date and unit].[supervisors meeting]) AS [Supervisors Meeting]
  18.      , ([unit hse statistics].[managers meeting]/[kpi targets by date and unit].[managers meeting]) AS [Managers Meeting]
  19.      , ([unit hse statistics].[pcar closed]/[kpi targets by date and unit].[pcar open]) AS [PCAR Open]
  20.      , ([unit hse statistics].[forklift inspections]/[kpi targets by date and unit].[forklift inspections]) AS [Forklift Inspections]
  21.      , ([unit hse statistics].[crane inspections]/[kpi targets by date and unit].[crane inspections]) AS [Crane Inspections]
  22.      , ([unit hse statistics].[vehicle inspections]/[kpi targets by date and unit].[vehicle inspections]) AS [Vehicle Inspections]
  23.      , ([unit hse statistics].[camp hygiene inspections]/[kpi targets by date and unit].[camp hygiene inspections]) AS [Camp Hygiene Inspections]
  24.      , ([unit hse statistics].[first aid inspection]/[kpi targets by date and unit].[first aid inspection]) AS [First Aid Inspection]
  25.      , ([unit hse statistics].[ppe inspection]/[kpi targets by date and unit].[ppe inspection]) AS [PPE Inspection]
  26.      , ([unit hse statistics].[mast inspections]/[kpi targets by date and unit].[mast inspections]) AS [Mast Inspections]
  27.      , ([unit hse statistics].[drillers inspection]/[kpi targets by date and unit].[drillers inspection]) AS [Drillers Inspection]
  28.      , ([unit hse statistics].[harness inspection]/[kpi targets by date and unit].[harness inspection]) AS [Harness Inspection]
  29.      , ([unit hse statistics].[scba inspection]/[kpi targets by date and unit].[scba inspection]) AS [SCBA Inspection]
  30.      , ([unit hse statistics].[fire extinguisher inspections]/[kpi targets by date and unit].[fire extinguisher inspections]) AS [Fire Extinguisher Inspections]
  31.      , ([unit hse statistics].[spill kit inspection]/[kpi targets by date and unit].[spill kit inspection]) AS [Spill Kit Inspection]
  32.      , ([unit hse statistics].[fire fighting cabinet inspection]/[kpi targets by date and unit].[fire fighting cabinet inspection]) AS [Fire Fighting Cabinet Inspection]
  33.      , ([unit hse statistics].[fall arrestors inspection]/[kpi targets by date and unit].[fall arrestors inspection]) AS [Fall Arrestors Inspection]
  34.      , ([unit hse statistics].[smoke detector inspection]/[kpi targets by date and unit].[smoke detector inspection]) AS [Smoke Detector Inspection]
  35.      , ([unit hse statistics].[rig inspection]/[kpi targets by date and unit].[rig inspection]) AS [Rig Inspection]
  36.      , ([unit hse statistics].[hse rep inspection]/[kpi targets by date and unit].[hse rep inspection]) AS [HSE Rep Inspection]
  37.      , ([unit hse statistics].[work orders open]/[kpi targets by date and unit].[work orders open]) AS [Work Orders Open]
  38.      , ([unit hse statistics].[work orders closed]/[kpi targets by date and unit].[work orders closed]) AS [Work Orders Closed]
  39.      , ([unit hse statistics].[training hours]/[kpi targets by date and unit].[training hours]) AS [Training Hours]
  40.      , ([unit hse statistics].[orientations]/[kpi targets by date and unit].[orientations]) AS Orientations
  41.      , ([unit hse statistics].[tool box talks]/[kpi targets by date and unit].[tool box talks]) AS [Tool Box Talks]
  42.      , ([unit hse statistics].[observation cards]/[kpi targets by date and unit].[observation cards]) AS [Observation Cards]
  43.      , ([unit hse statistics].[bop op drills]/[kpi targets by date and unit].[bop op drills]) AS [BOP Op Drills]
  44.      , ([unit hse statistics].[emergency drills]/[kpi targets by date and unit].[emergency drills]) AS [Emergency Drills]
  45.      , ([unit hse statistics].[waste disposal tickets]/[kpi targets by date and unit].[waste disposal tickets]) AS [Waste Disposal Tickets]
  46. FROM   [Unit HSE Statistics]
  47.      , [KPI Targets by Date and Unit];
Jan 15 '13 #4
NeoPa
32,556 Expert Mod 16PB
As I see nothing that indicates it would be related to any department I fail to see what you say. However, although it's quite messy, one can make the changes :
Expand|Select|Wrap|Line Numbers
  1. SELECT tUnit.[Date:]
  2.      , IIf(tKPI.[jsa]=0,1,
  3.            tUnit.[jsa]/tKPI.[jsa]) AS JSA
  4.      , IIf(tKPI.[cold work permit]=0,1,
  5.            tUnit.[cold work permit]/tKPI.[cold work permit]) AS [Cold Work Permit]
  6.      , IIf(tKPI.[hot work permit]=0,1,
  7.            tUnit.[hot work permit]/tKPI.[hot work permit]) AS [Hot Work Permit]
  8.      , IIf(tKPI.[man rider permit]=0,1,
  9.            tUnit.[man rider permit]/tKPI.[man rider permit]) AS [Man Rider Permit]
  10.      , IIf(tKPI.[live circut permit]=0,1,
  11.            tUnit.[live circut permit]/tKPI.[live circut permit]) AS [Live Circut Permit]
  12.      , IIf(tKPI.[confined space permit]=0,1,
  13.            tUnit.[confined space permit]/tKPI.[confined space permit]) AS [Confined Space Permit]
  14.      , IIf(tKPI.[radioactive permit]=0,1,
  15.            tUnit.[radioactive permit]/tKPI.[radioactive permit]) AS [Radioactive Permit]
  16.      , IIf(tKPI.[diesel transfer permit]=0,1,
  17.            tUnit.[diesel transfer permit]/tKPI.[diesel transfer permit]) AS [Diesel Transfer Permit]
  18.      , IIf(tKPI.[gas tests performed]=0,1,
  19.            tUnit.[gas tests performed]/tKPI.[gas tests performed]) AS [Gas Tests Performed]
  20.      , IIf(tKPI.[loto performed]=0,1,
  21.            tUnit.[loto performed]/tKPI.[loto performed]) AS [LOTO Performed]
  22.      , IIf(tKPI.[pre job meeting]=0,1,
  23.            tUnit.[pre job meeting]/tKPI.[pre job meeting]) AS [Pre Job Meeting]
  24.      , IIf(tKPI.[pre tour meetings]=0,1,
  25.            tUnit.[pre tour meetings]/tKPI.[pre tour meetings]) AS [Pre Tour Meetings]
  26.      , IIf(tKPI.[weekly hse meetings]=0,1,
  27.            tUnit.[weekly hse meetings]/tKPI.[weekly hse meetings]) AS [Weekly HSE Meetings]
  28.      , IIf(tKPI.[monthly hse meetings]=0,1,
  29.            tUnit.[monthly hse meetings]/tKPI.[monthly hse meetings]) AS [Monthly HSE Meetings]
  30.      , IIf(tKPI.[safety committee meetings]=0,1,
  31.            tUnit.[safety committee meetings]/tKPI.[safety committee meetings]) AS [Safety Committee Meetings]
  32.      , IIf(tKPI.[supervisors meeting]=0,1,
  33.            tUnit.[supervisors meeting]/tKPI.[supervisors meeting]) AS [Supervisors Meeting]
  34.      , IIf(tKPI.[managers meeting]=0,1,
  35.            tUnit.[managers meeting]/tKPI.[managers meeting]) AS [Managers Meeting]
  36.      , IIf(tKPI.[pcar open]=0,1,
  37.            tUnit.[pcar closed]/tKPI.[pcar open]) AS [PCAR Open]
  38.      , IIf(tKPI.[forklift inspections]=0,1,
  39.            tUnit.[forklift inspections]/tKPI.[forklift inspections]) AS [Forklift Inspections]
  40.      , IIf(tKPI.[crane inspections]=0,1,
  41.            tUnit.[crane inspections]/tKPI.[crane inspections]) AS [Crane Inspections]
  42.      , IIf(tKPI.[vehicle inspections]=0,1,
  43.            tUnit.[vehicle inspections]/tKPI.[vehicle inspections]) AS [Vehicle Inspections]
  44.      , IIf(tKPI.[camp hygiene inspections]=0,1,
  45.            tUnit.[camp hygiene inspections]/tKPI.[camp hygiene inspections]) AS [Camp Hygiene Inspections]
  46.      , IIf(tKPI.[first aid inspection]=0,1,
  47.            tUnit.[first aid inspection]/tKPI.[first aid inspection]) AS [First Aid Inspection]
  48.      , IIf(tKPI.[ppe inspection]=0,1,
  49.            tUnit.[ppe inspection]/tKPI.[ppe inspection]) AS [PPE Inspection]
  50.      , IIf(tKPI.[mast inspections]=0,1,
  51.            tUnit.[mast inspections]/tKPI.[mast inspections]) AS [Mast Inspections]
  52.      , IIf(tKPI.[drillers inspection]=0,1,
  53.            tUnit.[drillers inspection]/tKPI.[drillers inspection]) AS [Drillers Inspection]
  54.      , IIf(tKPI.[harness inspection]=0,1,
  55.            tUnit.[harness inspection]/tKPI.[harness inspection]) AS [Harness Inspection]
  56.      , IIf(tKPI.[scba inspection]=0,1,
  57.            tUnit.[scba inspection]/tKPI.[scba inspection]) AS [SCBA Inspection]
  58.      , IIf(tKPI.[fire extinguisher inspections]=0,1,
  59.            tUnit.[fire extinguisher inspections]/tKPI.[fire extinguisher inspections]) AS [Fire Extinguisher Inspections]
  60.      , IIf(tKPI.[spill kit inspection]=0,1,
  61.            tUnit.[spill kit inspection]/tKPI.[spill kit inspection]) AS [Spill Kit Inspection]
  62.      , IIf(tKPI.[fire fighting cabinet inspection]=0,1,
  63.            tUnit.[fire fighting cabinet inspection]/tKPI.[fire fighting cabinet inspection]) AS [Fire Fighting Cabinet Inspection]
  64.      , IIf(tKPI.[fall arrestors inspection]=0,1,
  65.            tUnit.[fall arrestors inspection]/tKPI.[fall arrestors inspection]) AS [Fall Arrestors Inspection]
  66.      , IIf(tKPI.[smoke detector inspection]=0,1,
  67.            tUnit.[smoke detector inspection]/tKPI.[smoke detector inspection]) AS [Smoke Detector Inspection]
  68.      , IIf(tKPI.[rig inspection]=0,1,
  69.            tUnit.[rig inspection]/tKPI.[rig inspection]) AS [Rig Inspection]
  70.      , IIf(tKPI.[hse rep inspection]=0,1,
  71.            tUnit.[hse rep inspection]/tKPI.[hse rep inspection]) AS [HSE Rep Inspection]
  72.      , IIf(tKPI.[work orders open]=0,1,
  73.            tUnit.[work orders open]/tKPI.[work orders open]) AS [Work Orders Open]
  74.      , IIf(tKPI.[work orders closed]=0,1,
  75.            tUnit.[work orders closed]/tKPI.[work orders closed]) AS [Work Orders Closed]
  76.      , IIf(tKPI.[training hours]=0,1,
  77.            tUnit.[training hours]/tKPI.[training hours]) AS [Training Hours]
  78.      , IIf(tKPI.[orientations]=0,1,
  79.            tUnit.[orientations]/tKPI.[orientations]) AS Orientations
  80.      , IIf(tKPI.[tool box talks]=0,1,
  81.            tUnit.[tool box talks]/tKPI.[tool box talks]) AS [Tool Box Talks]
  82.      , IIf(tKPI.[observation cards]=0,1,
  83.            tUnit.[observation cards]/tKPI.[observation cards]) AS [Observation Cards]
  84.      , IIf(tKPI.[bop op drills]=0,1,
  85.            tUnit.[bop op drills]/tKPI.[bop op drills]) AS [BOP Op Drills]
  86.      , IIf(tKPI.[emergency drills]=0,1,
  87.            tUnit.[emergency drills]/tKPI.[emergency drills]) AS [Emergency Drills]
  88.      , IIf(tKPI.[waste disposal tickets]=0,1,
  89.            tUnit.[waste disposal tickets]/tKPI.[waste disposal tickets]) AS [Waste Disposal Tickets]
  90. FROM   [Unit HSE Statistics] AS tUnit
  91.      , [KPI Targets by Date and Unit] AS tKPI
Jan 15 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: franknavec | last post by:
I have created a database in MS Access 2000. I want to compute for percent defective and in the control source I have this expression: =((/)*100). Its OK if I have the numbers greater than zero....
6
by: Chuck Yeager via DotNetMonster.com | last post by:
I think I am giong to die, this is driving us nuts. Here is the error we are getting when trying to use CrystalReportViewer: OS: XP SP1 and another machine XP SP2 (same errors) IDE: VS .NET...
5
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
2
by: sierra7 | last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control. I have a form which has been...
0
by: Andolino | last post by:
In Access 2010 I get a Write Conflict error - "This record has been changed by another user..." In Access 2007 this Code is working - why? Private Sub Form_BeforeUpdate(Cancel As Integer) Dim...
1
by: Alan Yim | last post by:
Hi folks, My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question...
2
by: Bill Boord | last post by:
I need to be able to shut off the AutoCorrect "feature" within Access 2010 code. I have utilized Application.SetOption with method strings for other startup requirements, but I cannot seem to find a...
1
dsatino
by: dsatino | last post by:
I have numerous applications built in Access 2000/2003 that all use ODBCdirect workspaces to access various non-Access databases. Unfortunately, ODBCdirect is 'no longer supported'in Access 2010 and...
0
by: Lysander | last post by:
I'm sure many of you use backend and frontend databases. The backend holds all the tables, the frontend holds all the code. If you are developing for a multi-user system, you may have the same...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.