469,276 Members | 1,774 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,276 developers. It's quick & easy.

VBA Overflow Error - Again

1
I have found TheScripts a very useful site, but however I cannot find an answer to a problem I am having, so I finally have to ask the question!

I am getting an Overflow error in a Function I have written.

BUT... It does not occur all the time.

If I call the Function from the "After Update" event for a checkbox, it works as intended, how ever if I call the Function from the "On Load" event of the Form, testing to see whether the checkbox's value is True I get the Overflow Error.

To confirm this, I set a break point below where I was getting the error. If called via the "After Update" event, the variable has the right value, but if it is called from the "On Load" event that variable holds 0.

This is the code snippet that is causing the problem:

Dim adjustHours As Integer
Dim averagePay As Currency

If Me.projectAllocatedHours.Enabled = True Then

adjustHours = Me.projectAllocatedHours - Me.projectTotalHours
averagePay = Me.tempAveragePay

' The above line is the one causing grief
...

End If

From what I have read, the definition of an overflow error is "Overflow means the number is too large for the data type."

as this works one way, and not the other it has me stumped.

Thanks in advance for your help.

Zane
Mar 14 '07 #1
1 3090
missinglinq
3,532 Expert 2GB
It would probably help us to help you if you would post the code for the function that you're calling! I'm also a little confused as to why you'd call a function in the Form_Load event to check to see if a checkbox's value was True! The function would only be checking this for the first record in the form, ignoring any other records. A more appropriate place would probably be in the Form_Current event.
Mar 14 '07 #2

Post your reply

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

Similar topics

1 post views Thread by xixi | last post: by
20 posts views Thread by Bronek Kozicki | last post: by
25 posts views Thread by junky_fellow | last post: by
10 posts views Thread by Parachute | last post: by
3 posts views Thread by subramanian100in | last post: by
3 posts views Thread by jer006 | last post: by
2 posts views Thread by jgscott3 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.