Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

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?
Avatar of Bill Prew
Bill Prew

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
Avatar of SteveL13

ASKER

Yes.  It is zero.  How do I fix the code?
See above, I updated my comment...


»bp
Still getting overflow.  Both txtActualHours and txtFee are zero.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

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
txtFee is currency.  txtActualHours is Number, single, standard, 2.   txtDollarsPerHour is currency.
This worked:

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

Thanks!
Welcome, glad that helped.


»bp