D
Don Seckler
I have a form with a button. When the fields are filled in and the
button is clicked, the code below checks to see if a record with the
same data already exists. If it does the error kicks in and the pop
up comes up saying that the record already exists, would you like to
edit the existing record.
Next I have "editForm" opening, so the user can edit the record. How
do I get the record that triggered the error to be the active one in
"editForm" when it opens?
Private Sub ButtonAddDraw_Click()
On Error GoTo Err_ButtonAddDraw_Click
DoCmd.GoToRecord , , acNewRec
Exit_ButtonAddDraw_Click:
Exit Sub
Err_ButtonAddDraw_Click:
Select Case Err.Number
Case 2105
Err.Clear
'* Display my custom message box
If MsgBox("The draw has already been entered for this issue.
Would you like to edit it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "EditForm"
Else
End If
GoTo Exit_ButtonAddDraw_Click
Case Else
MsgBox Err.Description
End Select
Resume Exit_ButtonAddDraw_Click
button is clicked, the code below checks to see if a record with the
same data already exists. If it does the error kicks in and the pop
up comes up saying that the record already exists, would you like to
edit the existing record.
Next I have "editForm" opening, so the user can edit the record. How
do I get the record that triggered the error to be the active one in
"editForm" when it opens?
Private Sub ButtonAddDraw_Click()
On Error GoTo Err_ButtonAddDraw_Click
DoCmd.GoToRecord , , acNewRec
Exit_ButtonAddDraw_Click:
Exit Sub
Err_ButtonAddDraw_Click:
Select Case Err.Number
Case 2105
Err.Clear
'* Display my custom message box
If MsgBox("The draw has already been entered for this issue.
Would you like to edit it?", vbYesNo) = vbYes Then
DoCmd.OpenForm "EditForm"
Else
End If
GoTo Exit_ButtonAddDraw_Click
Case Else
MsgBox Err.Description
End Select
Resume Exit_ButtonAddDraw_Click