An overflow results when you try to make an assignment that exceeds the limitations of the target of the assignment. This error has the following causes and solutions:
The result of an assignment, calculation, or data type conversion is too large to be represented within the range of values allowed for that type of variable.
Assign the value to a variable of a type that can hold a larger range of values.
An assignment to a property exceeds the maximum value the property can accept.
Make sure your assignment fits the range for the property to which it is made.
You attempt to use a number in a calculation, and that number is coerced into an integer, but the result is larger than an integer. For example:
Dim x As Long
x = 2000 * 365 ' Error: Overflow
To work around this situation, type the number, like this:
Dim x As Long
x = CLng(2000) * 365
For additional information, select the item in question and press F1 (in Windows) or HELP (on the Macintosh).
Ok, quick question. Is there a way to force and error number to see the definition. The issue is my program is used by other countries that have their Windows set up in their own language. The program works fine on all other machines. So I have error traps all over the place that tells me the Error number, definition and the procedure that the error occured. Only problem is that when they send me a screenshot, the number and procedure come over in English but the err.description is in Chinese for example. So even though I know what procedure to look in, I have no clue where at or what caused the error.
You could always try add the Erl function to your error trapping. It is not documented in the VBA help file (I can't seem to find it, at any rate), but if you have numbered the lines of code, you can return at what line number the error occurred.
In this example, I have saved the name of each sub in a variable named ErrSource so when the error does occurr I know which macro the error was in. It then returns the line number, error number and description.
In your case, the description would still be in a different language, but you could also get the other information.
I fixed my original error, but for future reference.
Your message box looks almost identical to mine not counting the erl function. I will try this. I was placing a public variable called intErrNum and troughout the code I would hard code a number for it and pass that to my error procedure which is (variables)
An Unexpected Error has occured,
Please contact (curPgr) with the following information
Error Number: (err.Number)
Error Decription: (err.Description)
Error Procedure: (PrcName & " " & intErrNum)
At the end of each procedure of my code I have
So will erl replace my intErrNum and then how do I find that line again.
As explained in the example I linked to in the previous post, you have to add line numbers in the code itself. That's the only way the Erl function will work.
Dim ErrSource As String
10 ErrSource = "test" 'the name of the sub
On Error GoTo ErrHandler:
20 Debug.Print "Some Code Here"
30 Debug.Print "More Code Here"
'this causes an error that will be trapped by the error handler
40 Err.Raise 1
50 Exit Sub
60 MsgBox "An error has occurred." & vbCrLf & _
"Please inform Kristy of this information:" & _
String(2, vbCrLf) & "Sub: " & ErrSource & _
vbCrLf & "Line: " & Erl & vbCrLf & _
"Error: " & Err.Number & vbCrLf & "Description: " & _
Err.Description & String(2, vbCrLf), vbOKOnly + vbCritical, "Error"
As far as numbering the lines goes, you can do it manually or find/write a program to automatically do it. I know that the MZ-Tools add-in has this ability (it's also a generally handy add-in, in my opinion). http://www.mztools.com/index.htm