Link to home
Start Free TrialLog in
Avatar of SparkyP
SparkyP

asked on

No Data Subform

I have a Dashboard/Switchboard Form that has a unbound subform, based on a query that looks at a score from an Answers Table.

On the Dashboard Form I have an unbound textbox "Text38"  which displays text based on the results of the percentage field in the subform, using the following code on the On Current Event:

If IsNull(Me!mjpMaxScore!Percentage) Then
Me!Text38.Visible = False
ElseIf Me!mjpMaxScore!Percentage >= 85 Then
Me!Text38 = "World Class"
ElseIf Me!mjpMaxScore!Percentage < 85 And Me!mjpMaxScore!Percentage >= 70 Then
Me!Text38 = "Good Operational Standard"
ElseIf Me!mjpMaxScore!Percentage < 70 And Me!mjpMaxScore!Percentage >= 40 Then
Me!Text38 = "Acceptable - Further Action Required"
ElseIf Me!mjpMaxScore!Percentage < 40 And Me!mjpMaxScore!Percentage > 0 Then
Me!Text38 = "Poor - Immediate Action Required"
ElseIf Me!mjpMaxScore!Percentage = 0 Then
Me!Text38 = "No Questions Answered or All Major N/C"
End IF

This works perfectly when there is data, but throws up "Runtime Error 2427 -you have entered an invalid expression that has no value"

How do I deal with this, please?

Thanks in anticipation.
SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SparkyP
SparkyP

ASKER

Many Thanks Jim

The Calc is from a Query which has several Calcs that display in the subform, ie. Sum of questions, sum of question answered etc.

Obviously if no questions have been asked or answered the query has no results.

The percentage calc is the one that is used to display the text.

Sorry for any confusion.
So, is this code in the Current event of the subform?

Jim, like that AvoidError function, why didn't I ever think of that?  So, to avoid a divide by zero error, you would do something like?

Percentage: AvoidError([SomeField]/[SomeOtherField], 99)
Avatar of SparkyP

ASKER

Dale

On Current in the Main Form
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SparkyP

ASKER

Thanks Both

Works like a dream