Valery
Registered User.
- Local time
- Today, 09:27
- Joined
- Jun 22, 2013
- Messages
- 363
Hi all!
I am a newbie... really trying to learn. I have a command button on a subform (main form = frmUnitUpd / subform = frmUnitUpd_Tenants ) to allow the deletion of a record. I wish to:
1) ad a warning message - "Was this record entered by mistake?"
If user clicks on "yes" - have the query called qryDelRecord open to that record (link field is TenantsID) and allow the user to delete the record. When the query is closed, the user should be returned to the form, with that record gone.
If user clicks on "no" - do nothing.
I have this coding from a previous database where someone generous like yourself, helped me. But I don't know how to adapt it.
Thank you!
I am a newbie... really trying to learn. I have a command button on a subform (main form = frmUnitUpd / subform = frmUnitUpd_Tenants ) to allow the deletion of a record. I wish to:
1) ad a warning message - "Was this record entered by mistake?"
If user clicks on "yes" - have the query called qryDelRecord open to that record (link field is TenantsID) and allow the user to delete the record. When the query is closed, the user should be returned to the form, with that record gone.
If user clicks on "no" - do nothing.
I have this coding from a previous database where someone generous like yourself, helped me. But I don't know how to adapt it.
Code:
Private Sub DeleteCurrentRecord_Click()
Dim Msg, Style, Title, Help, Ctxt, Response, MyString
Msg = "Was this record entered by mistake?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
' Display message.
Response = MsgBox(Msg, Style, Title, Help, Ctxt)
If Response = vbYes Then ' User chose Yes.
MyString = "Yes" ' Perform some action.
Else ' User chose No.
MyString = "No" ' Perform some action.
End If
End Sub
Thank you!