Duplicate Values in the Index

rs2004

New member
Local time
Today, 04:48
Joined
Oct 21, 2004
Messages
7
If you index a field in a table to Yes(No Duplicates) to prevent , say an address being entered twice, Is there a way to Trap the Error on a Form when it occurs in VBA? What would be the Error Number for the On Error statement?
 
Last edited:
rs2004 said:
Is there a way to Trap the Error on a Form when it occurs in VBA?

Simply use On Error Goto... statement

Filippo
 
ErrorTrap

Would you happen to know the error number by any chance?
 
Look at the Err Object Example in Access Help

Is it what your looking for?

Filippo
 
Duplicate Record Error

Thanks for responding. The duplicate record error message doesnt appear until i move to another record. So I dont know where to put the code to try to identifiy there ERR number.
 
In a bound form, this would be a form error, not a runtime error. Then you can try the forms on error event. I think duplicate key is 3022 (probably the same as the runtime error doing a programattic update), so something like this in the forms on error event:

if dataerr=3022 then
msgbox "your custom message"
response=acdataerrcontinue
end if

Note - this isn't validation, simply replacing Access inbuilt message box with ones own.
 
Thank you,

I was missing the

Code:
response=acdataerrcontinue

until you brought this to my attention

thanks

sportsguy
 

Users who are viewing this thread

Back
Top Bottom