How do I trap the error?

  • Thread starter Thread starter Bonnie
  • Start date Start date
B

Bonnie

Hi there! Using A02 on XP. I set my table with a multiple
key index to avoid duplicate records. When clicking the
Close button, the duplicates were not being added but no
message was telling them they weren't. I added the save
record line and now we get the message that the record
couldn't be added yada yada and you are back on the form
still in edit mode with nothing saved. If I then change
the data in the field that is keeping me from saving the
record and click the Close button again I get the
Microsoft Access - Reserved Error. Click okay on the
error, click the Close button one more time and it closes
and saves the corrected new record. What am I doing wrong?

Private Sub CloseButton_Click()
On Error GoTo Err_CloseButton_Click

DoCmd.RunCommand acCmdSaveRecord
DoCmd.close

Exit_CloseButton_Click:
Exit Sub

Err_CloseButton_Click:
MsgBox Error$
Resume Exit_CloseButton_Click

End Sub

Thanks in advance for ANY help or advice!!!
 
A "Reserved Error" indicates something happened that the Microsoft
developers did not expect to occur.

First thing to check would be that you have at least Service Pack 2 for
Office 2002. The Help About screen should contain "SP2" if you do. If not,
go to support.microsoft.com, and download the SP2 or SP3.

You should also check you have the latest JET serrice pack, available from
the Downloads section of the same site.

If this does not solve the problem, make sure your code compiles: Compile
from Debug menu (from the code window).

As an alternative to "DoCmd.RunCommand acCmdSaveRecord", you could try
setting the Dirty property of the form, i.e.:
If Me.Dirty Then
Me.Dirty = False
End If
 
Thanks BUNCHES for the advice. I learn something every
time I get in here. Thanks for taking the time to help
others!
 
Back
Top