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

Prevent standard "Do you want to delete...." from showing 1

Status
Not open for further replies.

DevelopV

Technical User
Mar 16, 2012
113
ZA
If a user selects a records on a continuous form, and hits the delete key, I display a customised message is displayed asking the user to confirm if they want to delete the record.

Code:
Private Sub Form_Delete(Cancel As Integer)

Dim response As Integer

response = MsgBox("Do you really want to delete:" & vbLf & vbLf & _
                  Me.Field1 & "?", vbQuestion + vbYesNo, "Delete Record?")

If response = vbNo Then
    Cancel = True
    Exit Sub
End If

End Sub

If the user selects "Yes", Access displays message that a record is going to be deleted.
How can I prevent this second message from being displayed. This message also give the user the option to abort the deletion, which I do not want.

Thanks in advance
 
Have a look at the DoCmd.SetWarnings method.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
In your Delete event procedure add the following just before the End Sub line:
DoCmd.SetWarnings False

And in the Current event procedure of the form:
DoCmd.SetWarnings True

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya DevelopV . . .

If you transfer your code (message prompt) to the [blue]Before Del Confirm[/blue] event you'll need to add one line. You'll also need to change the name of your [blue]Response[/blue] variable as the event has [blue]Response[/blue] as one of its arguements. Renaming with [[purple]usrAns[/purple] we have:
Code:
[blue]Private Sub Form_BeforeDelConfirm(Cancel As Integer, response As Integer)
   Dim [purple][b]usrAns[/b][/purple] As Integer
   
   [purple][b]response = acDataErrContinue[/b][/purple] [green]' no delete comfirm dialog![/green]
   
   [purple][b]usrAns[/b][/purple] = MsgBox("Do you really want to delete:" & vbLf & vbLf & _
                     Me.Field1 & "?", vbQuestion + vbYesNo, "Delete Record?")
   
   If [purple][b]usrAns[/b][/purple] = vbNo Then
       Cancel = True
   End If

End Sub[/blue]

[blue]Your Thoughts? . . .[/blue]

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top