I have a table that has the following columns:
Reg
Dept
Electronic Volume
Outcry Volume
Volume
Reg and Dept are primary keys in this table. Sometimes it is necessary to add a reg and dept (this is a Access 2007 front end to an SQL Server 2005 back end table) with the associated volumes. I want to have a usable error message when the user tries to insert a row that has a duplicate reg and dept or a missing reg and/or dept instead of the canned Microsoft error message. I have tried putting the error message in the Form After Update and Form After Insert but this has not worked. Here is the code I have used:
Private Sub Form_AfterInsert()
On Error GoTo err_handler
Me.Requery
endit:
Exit Sub
err_handler:
MsgBox "Error has occurred due to duplicate values or blank lines. Please press the ESCAPE button to delete the bad lines and re-enter the information again.", vbOKOnly
Resume endit
End Sub
Any suggestions? Any help would be appreciated. Thanks.
Dave
Reg
Dept
Electronic Volume
Outcry Volume
Volume
Reg and Dept are primary keys in this table. Sometimes it is necessary to add a reg and dept (this is a Access 2007 front end to an SQL Server 2005 back end table) with the associated volumes. I want to have a usable error message when the user tries to insert a row that has a duplicate reg and dept or a missing reg and/or dept instead of the canned Microsoft error message. I have tried putting the error message in the Form After Update and Form After Insert but this has not worked. Here is the code I have used:
Private Sub Form_AfterInsert()
On Error GoTo err_handler
Me.Requery
endit:
Exit Sub
err_handler:
MsgBox "Error has occurred due to duplicate values or blank lines. Please press the ESCAPE button to delete the bad lines and re-enter the information again.", vbOKOnly
Resume endit
End Sub
Any suggestions? Any help would be appreciated. Thanks.
Dave