Avatar of wlwebb
wlwebbFlag for United States of America

asked on 

Access - #Error when Control Source formula has a blank subform value

I have a tabbed form that on one of the tabs I have 4 subforms.  On the tabbed form I have a textbox to display for the user the % Complete that a Job is by comparing the Total Actual Cost vs the Total Estimated Cost.

I am taking a textbox totals field of one subform and using it to compute a % of completion from a textbox totals field from another subform.

When one of the subforms is blank (ie: no costs have been input on a job yet) then I get #Error.

I have tried IIF() statements and Error$ to get it to display as 0% when it is computing #Error.  I can not get the syntax correct.

Below is my formula.  What do I change to get it to display as 0% if it is in #Error?
=Nz([sfrmJobSummaryItemTotalsOnly].[Form]![txtTotalAllItems]/[sfrmJCJobEstimateEstimatedCosts].[Form]![Item Cost Estimate],0)

Open in new window

Microsoft Access

Avatar of undefined
Last Comment
Rey Obrero (Capricorn1)
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

try this one


=IIF(nz([sfrmJobSummaryItemTotalsOnly].[Form]![txtTotalAllItems],0)=0,0,[sfrmJobSummaryItemTotalsOnly].[Form]![txtTotalAllItems]/nz([sfrmJCJobEstimateEstimatedCosts].[Form]![Item Cost Estimate],0)
I use the IsError()

Try:

=IIf(IsError([sfrmJobSummaryItemTotalsOnly].[Form]![txtTotalAllItems])=True,0,Nz([sfrmJobSummaryItemTotalsOnly].[Form]![txtTotalAllItems],0)/Nz([sfrmJCJobEstimateEstimatedCosts].[Form]![Item Cost Estimate],0))

Open in new window


The issue will be if [sfrmJCJobEstimateEstimatedCosts].[Form]![Item Cost Estimate] is zero (0).

ASKER CERTIFIED SOLUTION
Avatar of Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Boyd (HiTechCoach) Trimmell, Microsoft Access MVP 2010-2015
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of danishani
danishani
Flag of United States of America image

Also check this link out about #Error if you have no records in Subform:

http://access.mvps.org/access/forms/frm0022.htm

HTH,
Daniel
Avatar of wlwebb
wlwebb
Flag of United States of America image

ASKER

Worked like a charm.  Thanks to all that replied!!
my mistake should have posted, oh well ;-(

=IIF(nz([sfrmJCJobEstimateEstimatedCosts].[Form]![Item Cost Estimate],0)=0,0,[sfrmJobSummaryItemTotalsOnly].[Form]![txtTotalAllItems]/[sfrmJCJobEstimateEstimatedCosts].[Form]![Item Cost Estimate])
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo