Re: run-time error 5



Hello, lj,

The symptoms disappearing in debug mode make it sound as if a timing problem is a possibility. You are "showing" the form twice in rapid succession. Could this be the source of the difficulty.

> ShowNextForm GetReportVersion, 1
> GetReportVersion.Show

If you don't have a reason for showing the form twice, try removing the second one. If you actually have a reason for showing the form twice, try putting a DoEvents between the two calls to see if this helps.

Cheers,
Randy


ljswihart@xxxxxxxxxx wrote:
I have a Visual Basic executable which errors out
with a run-time error '5': Invalid procedure call or argument. I have
error handling in every procedure. When debugging the error doesn't
occur. I click on a command button which calls a form and it also runs
a procedure that gathers some data. If I comment out the procedure
that gathers some data, I don't get the error. Or vice versa if I
don't call the form and just run the procedure that gathers the data I
don't get the error. It's only the combination of the 2 that pulls in
the runtime error 5. Below is the code used to load the form. If you
notice, I put a msgbox in the handle error. Even though it errors, it
never goes through the handle error. Please help.

Private Sub cmdLdgTally_Click()
ShowNextForm GetReportVersion, 1
GetReportVersion.Show
Print_Loading_Tally_Report ScanBundle, RptVersion
Exit Sub
HandleError:
MsgBox (Err.Number)
gErrResp = What_To_Do_On_Error(Err.Number, "Scan Bundle,
cmdLdgTally_Click")
Select Case gErrResp
Case 1
Resume
Case 2
Resume Next
Case 5
End Select
End Sub


Separate global module that is used with all of our other 300 compiled
programs.

Sub ShowNextForm(FName As Form, ShowStyle As Integer)
CurrentForm = CurrentForm + 1
Set FormMap(CurrentForm) = FName
FormMap(CurrentForm).Show ShowStyle
End Sub

Sub ShowPreviousForm()
CurrentForm = CurrentForm - 1
FormMap(CurrentForm).Show
End Sub

.


Loading