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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Confirmation

Status
Not open for further replies.

ptrifile

Technical User
Aug 10, 2004
457
US
I use the following code on a button to allow a user to delete a company name from a table, however, I would like to add a pop up box that will ask if the user really wants to delete the company Yes or No. Can someone help me with this? thanks!!

Code:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

    Dim stDocName As String

    stDocName = "delete_company"
    DoCmd.OpenQuery stDocName, acNormal, acEdit
    
    
MsgBox "company has been Deleted"

Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox err.Description
    Resume Exit_Command1_Click
    
    
    
End Sub

 
Code:
Dim choice as Integer
choice = MsgBox("This will delete the company record.  Are you sure?", vbYesNo)

If choice = vbYes Then
    'user said yes, code here
ElseIf choice = vbNo Then
    'user said no, code here
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top