milkman2500
Registered User.
- Local time
- Today, 13:28
- Joined
- Oct 21, 2012
- Messages
- 45
Hi,
I've read a few other threads about this but the suggestions offered didn't work for me. I'm hoping I can paste my code here and someone might be able to help.
I want a message box to appear when the user clicks "Ok". The message back should ask the user to confirm adding a new client. If they click cancel, I want the form to close and no new record to be added to the underlying table. If they click Ok, I want the record to be added to the table and the form to close.
I've read a few other threads about this but the suggestions offered didn't work for me. I'm hoping I can paste my code here and someone might be able to help.
I want a message box to appear when the user clicks "Ok". The message back should ask the user to confirm adding a new client. If they click cancel, I want the form to close and no new record to be added to the underlying table. If they click Ok, I want the record to be added to the table and the form to close.
Code:
Private Sub submit_button_Click()
Dim response As Integer
response = MsgBox("Are you sure you want to add this new client?", vbOKCancel, "Confirm adding new client")
If response = vbOK Then
DoCmd.Close acForm, "addClient", acSaveNo
Else
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.Close acForm, "addClient", acSaveNo
End If
End Sub