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
pdvsaProject financeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

OklahomaDaveCommented:
You're checking the wrong thing in your error handler. Just check for Err.Number=0 in the If statement and your problem should go away. The way you've written that IF statement, it will always evaluate to FALSE and force the ELSE portion to execute, causing the display of the message box you are experiencing.

Good luck.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
pdvsaProject financeAuthor Commented:
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...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.