Why getting an overflow error when tryint to open a form

I'm getting an overflow error when a form opens.  The code gets stuck on:

Me.txtDollarsPerHour = IIf(Me.txtActualHours = 0, 0, Me.txtDollarsPerHour = Me.txtFee / Me.txtActualHours)

Note:  If I put a breakpoint on the line then Me.DollarsPerHour is null.  Maybe that has something to do with it?
SteveL13Asked:
Who is Participating?
 
Bill PrewConnect With a Mentor Commented:
Sorry, exploring this a little further I think you will need a full IF statement, not an IIF to get around the zero case.

If txtActualHours = "0" Then
    txtDollarsPerHour = "0"
Else
    txtDollarsPerHour = txtFee / txtActualHours
End If

Open in new window


»bp
0
 
Bill PrewCommented:
It looks like the syntax may be off on your statement, you may want this (not worrying about data types for a minute...).

Me.txtDollarsPerHour = IIf(Me.txtActualHours = 0, 0, Me.txtFee / Me.txtActualHours)


»bp
0
 
SteveL13Author Commented:
Yes.  It is zero.  How do I fix the code?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
Bill PrewCommented:
See above, I updated my comment...


»bp
0
 
SteveL13Author Commented:
Still getting overflow.  Both txtActualHours and txtFee are zero.
0
 
SteveL13Author Commented:
txtFee is currency.  txtActualHours is Number, single, standard, 2.   txtDollarsPerHour is currency.
0
 
SteveL13Author Commented:
This worked:

If txtActualHours = "0" Then
    txtDollarsPerHour = "0"
Else
    txtDollarsPerHour = txtFee / txtActualHours
End If

Thanks!
0
 
Bill PrewCommented:
Welcome, glad that helped.


»bp
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.