Error Handling

P

Peter M.

I have the following code for a Save button on a standard
add/update/delete form. It's the code Access generates
for a Save record button...

Private Sub btnSave_Click()
On Error GoTo Err_btnSave_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu,
acSaveRecord, , acMenuVer70

Exit_btnSave_Click:
Exit Sub

Err_btnSave_Click:
MsgBox Err.Description
Resume Exit_btnSave_Click

End Sub


The problem is that it won't go to the Err_btnSave_Click
paragraph on a duplicate key error. It displays the
standard Access error 3146 message and that's all. I
cannot understand why it won't execute the
Err_btnSave_Click paragraph. I want to code my own error
handling.

Someone PLEASE help me.............
 
D

Dan Artuso

Hi,
It's been a while but I beleive you can trap this error in the Form's
Error event. Give it a shot. Just check the value of DataErr.
 
P

PeterM

Thanks...but that didn't work. I just realized that the
error is coming from ODBC. I'm using a MySQL back end
database via ODBC. Do you know how to trap an error from
ODBC?

I really appreciate your help!
-----Original Message-----
Hi,
It's been a while but I beleive you can trap this error in the Form's
Error event. Give it a shot. Just check the value of DataErr.

--
HTH
Dan Artuso, Access MVP


"Peter M." <[email protected]> wrote
in message news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top