Trap error for duplicate key

Papa_Bear_1352

New member
Local time
Today, 23:13
Joined
Jun 16, 2003
Messages
9
Hi all

I have a form attached to a table, the key being a text field.

When I add a record by clicking the star button and enter a dulicate key, I get the standard very wordy error message.

Which event do I use to trap this error so I can add my own message. I have tried afterupdate and afteradd but no success.

Steve
 
You need to use the On_Error event of your form.

Alternatively you can trap the error in the Before_Update event as well by adding a GoTo statement:

On Error GoTo ErrorTrap:

Your update code here

ErrorTrap:

Your ErrorTrap code here

HTH
Rob
 
Hi Again

I tried putting the following code in on_error event

MSGBOX("on errrr " & ERR.NO)

but it was never displayed, on_error event never invoked. In after_update, ERR.NO is zero.

Steve
 

Users who are viewing this thread

Back
Top Bottom