General discussion

Locked

Delete DB record

By Lord Foul ·
hi, i have a VB form linked to a db. i want to be able to delete an existing record (which i have done and it works) but i want to notify the user whether they want to continue with the operation or change their mind. i gather you need a msgbox witha yes/no option on it but when you click no in my program it still deleted the record. what coding do i need to put in after the msgbox to cancel the delete operation.
ghost

This conversation is currently closed to new comments.

5 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Delete DB record

by timfox In reply to Delete DB record

Check and double check your msgbox code and only execute your DELETE command after you are sure that the msgbox returns a yes. If it returns a 'no' - then don't execute your DELETE command. You should be assigning the return value of your msgbox similar to as follows:
dim response as integer
response = msgbox ("Are you sure you want to delete this record?", vbquestion+ vbyesno,"Confirm Action")
'Display result when debugging
msgbox "response was: " & response
if response = 6 then 'is yes =6?
'Insert delete command here
else
msgbox "Record not deleted.", vbinformation, "Action Cancelled"
end if

Does this help?

Collapse -

Delete DB record

by Lord Foul In reply to Delete DB record

yes it helped, thanks for your response

Collapse -

Delete DB record

by Mohammad_M_Saggaf In reply to Delete DB record

Hi,
In the click event of your Delete button but the following code:

Private Sub CmdDel_Click()
Dim Result As Long
Result = MsgBox("You attempt tot delete a record. Are you sure?", vbQuestion Or vbYesNo, "Deleting Record")
If Result = vbYes Then
' Deleting code

' Assuming you use a ADODC data control (ADODC).
Adodc1.Recordset.Delete adAffectCurrent

' Assuming you use a code ADO Recorset object (RSData).
RSData.Delete
End If
End Sub

I hope it helps.

Collapse -

Delete DB record

by Lord Foul In reply to Delete DB record

this pretty much follows along the same lines as the first response. thanks

Collapse -

Delete DB record

by Lord Foul In reply to Delete DB record

This question was closed by the author

Back to Web Development Forum
5 total posts (Page 1 of 1)  

Related Discussions

Related Forums