gusbrunston
Programmer
[tt]
Hi:
Error number 3022 is the form error that tells the user:[/tt]
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."
[tt]
I can successfully trap error number 3022 in the On Error event of the form with the following code, with which I trap the error, display a custom message box, return the focus to the offending control, and make the value null:
[/tt](Edited to fit)[tt]
Private Sub form_error(dataerr As Integer, & _
response As Integer)
If dataerr = 3022 Then
MsgBox "There is already a correcting " _
"record for this check. ", vbOKOnly, _
"Duplicate record"
DoCmd.DoMenuItem acFormBar, acEditMenu, _
acUndo, , acMenuVer70
Me.txtVoidCheck.SetFocus
Me.txtVoidCheck = Null
End If
End Sub
However, when the user clicks "OK" the good 'ole error message 3022 pops up again with that disagreeable "clunk", and the user has to click OK to get back to business.
Is there anyway I can completely trap and get rid of error 3022? I haven't been able to trap it in code behind the controls.
Appreciate your advice.
Cheers, and a happy new year.[/tt]
[tt]Gus Brunston - Access2000(DAO Intermediate skills.
Webmaster: www.rentdex.com[/tt]
Hi:
Error number 3022 is the form error that tells the user:[/tt]
"The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again."
[tt]
I can successfully trap error number 3022 in the On Error event of the form with the following code, with which I trap the error, display a custom message box, return the focus to the offending control, and make the value null:
[/tt](Edited to fit)[tt]
Private Sub form_error(dataerr As Integer, & _
response As Integer)
If dataerr = 3022 Then
MsgBox "There is already a correcting " _
"record for this check. ", vbOKOnly, _
"Duplicate record"
DoCmd.DoMenuItem acFormBar, acEditMenu, _
acUndo, , acMenuVer70
Me.txtVoidCheck.SetFocus
Me.txtVoidCheck = Null
End If
End Sub
However, when the user clicks "OK" the good 'ole error message 3022 pops up again with that disagreeable "clunk", and the user has to click OK to get back to business.
Is there anyway I can completely trap and get rid of error 3022? I haven't been able to trap it in code behind the controls.
Appreciate your advice.
Cheers, and a happy new year.[/tt]
![[glasses] [glasses] [glasses]](/data/assets/smilies/glasses.gif)
Webmaster: www.rentdex.com[/tt]