Delete Button

S

scott04

Hi everyone,
I am using the following code:
Private Sub DeleteRecord_Click()
Dim intResponse As String
intResponse = MsgBox("Do you wish to delete this record?", vbYesNo, "Delete
Record")
If intResponse = vbYes Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
Cancel = True
End If
End Sub
What i would like to do is rather than a message pop up, Have a message
popup that forces a user to manually type the word DELETE and then hit Ok.
If the user does not spell it correctly then ignore the delete. Can this be
done by modifiing my code? Thanks.
 
K

Klatuu

Starting a variable name with int ususally means it is an Integer numeric
variable. Not a rule, but a practice. A string variable name usually should
start with str.
Also, you can't cancel a command button click. You can tell if an event can
be canceled by looking at the event sub's arguments. If it doesn't say
Cancel As Integer, it can't be canceled.

Private Sub DeleteRecord_Click()
If InPutBox("Do you wish to delete this record?", "Delete") = "Delete"
Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
MsgBox "Delete Canceled"
End If
End Sub
 
S

scott04

Thanks for your help

Klatuu said:
Starting a variable name with int ususally means it is an Integer numeric
variable. Not a rule, but a practice. A string variable name usually should
start with str.
looking at the event sub's argAlso, you can't cancel a command button click. You can tell if an event can
be canceled by uments. If it doesn't say
Cancel As Integer, it can't be canceled.

Private Sub DeleteRecord_Click()
If InPutBox("Do you wish to delete this record?", "Delete") = "Delete"
Then
DoCmd.SetWarnings False
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
Else
MsgBox "Delete Canceled"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top