Link to home
Start Free TrialLog in
Avatar of pdvsa
pdvsaFlag for United States of America

asked on

Error Trap of "0"

Experts

I have this error display of "0" and I dont want this error msg to show.
I dont know what error it is because the code does what I want it to do.  
I can usually handle an error by defining it with an IF statement.
For some reason I seem to not be able to do the same if the error is 0.
You can see in my error handler I do put an IF error = 0 then exit sub but the code does not exit and still displays the error of 0 msbox.

If an error is 0, is it suppose to be handled like this or maybe there is obviously something else going on? (note that the INSERT code does do what it is suppose to do)


Private Sub Amount_BeforeUpdate(Cancel As Integer)

     On Error GoTo EH  '<-- add this for error handling
 

        Dim strSQL As String
If Not IsNull(Me.Amount) Then
'get an error if I try to save on before update
 'DoCmd.RunCommand acCmdSaveRecord

  strSQL = "INSERT INTO tblLCAmountHistory (fldDate, letterOfCreditID, EndUserID, LCNo, Amount) VALUES (#" & Format(Date, "m\/d\/yyyy") & "#," & Me!ID & "," & Me!EndUserID & ",'" & HyperlinkPart(Me!LCNo, acDisplayText) & "'," & Me!Amount & ")"
  
 
  Debug.Print strSQL
  
  DoCmd.SetWarnings False
  DoCmd.RunSQL strSQL
  DoCmd.SetWarnings True

Else

End If

   
EH:
   If Error = 0 Then
     Exit Sub
   Else
      
     MsgBox "Error: " & Err.Number & ": " & Err.Description
    End If
    

End Sub

Open in new window

untitled.JPG
ASKER CERTIFIED SOLUTION
Avatar of OklahomaDave
OklahomaDave

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

ASKER

Dave, that was it.  I remember this now. I wrote it down correctly in my word doc full of code but for some reason I keep forgetting to use the "Err.Number"

it works now.

thanks...