By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,560 Members | 1,494 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,560 IT Pros & Developers. It's quick & easy.

VBA Overflow Error - Again

P: 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.

Mar 14 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 2.5K+
P: 3,532
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.