Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Record with Confirm Before Deletion

Status
Not open for further replies.

RobotMush

Technical User
Aug 18, 2004
197
US
I have created the usual button for a form
"First Record"
"Previous Record"
"Next Record"
"Last Record"
"Add Record"
and
"Delete Record"
I have all the buttons but the Delete Record Button working. What I am wanting to do is to Have the current record that is displayed to be deleted,(The form only displays one record at a time) but instead of automatically deleting the record first have a confirm window pop up with the Yes/No choice. If yes, Current Record being Viewed is deleted, if No, Nothing Happens

Thank you for your help
Robot Mush (Technical User)
 
There is an event:
Code:
Private Sub Form_BeforeDelConfirm(Cancel As Integer, Response As Integer)
'Stuff
End Sub
 
On the OnClick event of your Delete button, you could put: (Change SomeFieldName to the name of a control to replace the focus)

Dim strMessage As String
Dim intOptions As Integer
Dim bytChoice As Byte

strmessage = "Are you sure you want to Delete this Record?"
intOptions = vbQuestion + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbCancel Then
SomeFieldName.SetFocus
Cancel = True
Else
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
End If
 
Or perhaps (?):
DoCmd.RunCommand acCmdDeleteRecord
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top