Mitsules, Mark S. (Newport News)
Mark.Mitsules at ngc.com
Mon Nov 17 13:02:55 CST 2003
Gina, Without chastising...hope this helps. Mark > how do I check for the violation Trap for error 2627, I believe. If this is not the correct error number, make the corrections in the code below. > Is there a way for me to replace that message with my own Yes. > where would I put the error message? In the error handler for the event. Something along the lines of: *************************************** 'A constant for the error number Const cErrDupPrimaryKey = 2627 FunctionExit: On Error Resume Next Exit Function ErrHandler: Select Case Err.Number Case cErrDupPrimaryKey 2627 'Insert your custom MsgBox here... MsgBox "Duplicate Primary Key. Please re-enter." _ , vbExclamation, "ErrHandler" Resume Next Case Else MsgBox "The application encountered an unexpected " & _ "error #" & Err.Number & " with message string '" & _ Err.Description & "'", _ vbExclamation, "ErrHandler" End Select Resume FunctionExit End Function *************************************** -----Original Message----- From: Gina Hoopes [mailto:hoopesg at hotmail.com] Sent: Monday, November 17, 2003 1:42 PM To: AccessD at databaseadvisors.com Subject: [AccessD] Primary Key Violation I've got a seemingly stupid question, but I can't figure it out. I've got a form that collects a staff member's first and last name and uses that combination as a primary key (unfortunately, no one can remember their employee ID and we don't collect SSN or anything unique they could enter). If they violate the exclusivity of that first/last name combination, they get the convoluted error message that Access puts out which only serves to confuse. Is there a way for me to replace that message with my own and, if so, how do I check for the violation and where would I put the error message? At the moment it comes up when they click the "done" button, which seems like a good place. Thanks, Gina p.s. Please don't chastise me for perceived primary key protocol violations. _________________________________________________________________ Send a QuickGreet with MSN Messenger http://www.msnmessenger-download.com/tracking/cdp_games _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com