Delete current record in form

jibb

Registered User.
Local time
Today, 12:12
Joined
Dec 1, 2011
Messages
93
Hello,

I am trying to add a delete button to a form to delete the current record but it always says the command deleterecord isnt available now.

Any ideas? My code is as follows-

Code:
Private Sub command11_Click()
Dim Answer As Integer
Answer = MsgBox("Are you sure you wish to delete this Purchase Order?", vbYesNo + vbExclamation + vbDefaultButton2, "Delete Confirmation")
If Answer = vbYes Then
DoCmd.SetWarnings False
    DoCmd.RunCommand acCmdSelectRecord
    DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True
End If
End Sub
 
Your code is perfectly valid, so the question is why isn't deleting possible? Is the Form's Allow Deletions Propery set to No? Is the Form based on a multi-Table Query that is Read-Only (most multi-Table Queries are Read-Only)? Do you have the correct Permissions to Delete from the Folder the database file resides in?

Linq ;0)>
 
Thanks,

There were some fields that werent enabled - it now doesnt show the error but doesnt delete the record. Allow deletions is set to yes, and I do have permissions - how do I check the query?
 
Open the Query independently and attempt to Delete or Edit a Record. I suspect you'll find that you can't which means that it's Read-Only.

For why Queries are Read-Only have a look at Allen Browne's article on the subject:

http://allenbrowne.com/ser-61.html

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom