delete current record

Darth Vodka

Registered User.
Local time
Today, 06:10
Joined
Sep 25, 2007
Messages
344
hi

when you get a button off the wizard to delette the current record, it does this for the code:-

DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70

and i don't like it

is there another way to delete current record? (i know i could construct the sql to do it...)
 
Code from one of my forms works in 97 and 2003

Code:
Private Sub cmdCancel_Click()
On Error GoTo Err_cmdCancel_Click

   If MsgBox("Once YES is selected this cancel cannot be undone", vbQuestion + vbYesNo, "Are you sure you wish to cancel this entire record?") = vbYes Then
      
        DoCmd.RunCommand acCmdSelectRecord
            DoCmd.RunCommand acCmdDeleteRecord
                DoCmd.Close acForm, "frmNewRec"
            DoCmd.Close acForm, "frmSelectNew"
        DoCmd.OpenForm "frmSwitchboard"
    End If
Exit_cmdCancel_Click:
    Exit Sub

Err_cmdCancel_Click:
    MsgBox "Record deleted"
    Resume Exit_cmdCancel_Click
    
End Sub
 
alternately you could create a SQL statement which captures the data from the form text boxes/ combos etc.. then refer this to your table and delete.

Simple and effective.
 

Users who are viewing this thread

Back
Top Bottom