Indexed field - modify error message

  • Thread starter Thread starter Tom
  • Start date Start date
T

Tom

Besides an existing AUTONUMBER id as the primary key, I
need to create a second field that won't allow any
duplicates.

I indexed the text field and specified "no duplicates".

Now, when testing data entry, I cannot enter the same
value in 2 different records (as expected).

Unfortunately though, MS-Access pops up a dialog box with
a rather long error message:

"The changes you requested to the table were not
successful because they would create duplicate values in
the index, ...
Changes the data in the field..., remove the index, etc."


Here's my question now:
=======================
How can I customize the Access dialog box so that I can
modify the error message?

For instance, I simply like to bring up a box which says
i.e. "Duplicate serial number - please enter unique serial
number".


Thanks,
Tom
 
I got answer in a different thread...

here's the function:




Private Sub Form_Error(DataErr As Integer, Response As
Integer)

'This is a quick way to display the error number can trap
it.
'Uncomment the next line to display the error number.
'MsgBox DataErr

'Once the error number has been identified, you can
delete or
'comment out the Msgbox line of code above.


'Now, plug in the error number (e.g. 3022) in next line.

If DataErr = 3022 Then
MsgBox "Duplicate UniqueID - please enter unique
value!"
Response = acDataErrContinue
Me!UniqueID = Null

'The Null line of code is just a convenience, so the user
'can just start typing again immediately after closing the
'message box.
End If
End Sub
 
Back
Top