PDA

View Full Version : Changing default error message



zaphod2003
09-10-2007, 06:56 AM
I have an access form which is linked to an access table and has a save button which when clicked attempts to save the data back to the table using the access standard save code:


Private Sub btnSaveRecord_Click()
On Error GoTo err_btnSaverecord_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
exit_btnSaveRecord_Click:
Exit Sub
err_btnSaverecord_Click:
MsgBox Err.description
Resume exit_btnSaveRecord_Click

End Sub


In itself this works fine except that if a record is duplicated it comes up with a message "The changes you requested to the table were not successful....... " etc etc

This message is too wordy and I want to change it to something else by interrupting this error. However, I only want to appear if and only if the user is trying to duplicate a record and not simply make updates to an existing record.

Any suggestions how I could modify the above method to do this?

OBP
09-10-2007, 12:26 PM
You can trap the error number and replace it's description with your own description.
Or you can check that it is a duplicate before trying to save the data.