Hi All,
I got a multiple delete working here but for some reason I occassionally get this error. The way the delete works is there is a text box where the user enters the quantity to delete. If it is blank it will delete 1 item. It never fails when I delete just 1 item but if I delete more than one item it fails but only some times. Here is the error:
"Run-time error '2046':
The command or action 'DeleteRecord' isn't available now."
Here is my code:
Private Sub cmdMultiDeleteR ecord_Click()
Dim DeletedQty As Integer
If Me.Dirty Then Me.Dirty = False
DoCmd.SetWarnin gs (WarningsOff)
If Not IsNull(Me.Numbe rDeleted) Then
DeletedQty = Me.NumberDelete d
Else
DeletedQty = 1
End If
If MsgBox("Are you sure you want to delete " & DeletedQty & " record(s)?", vbQuestion + vbYesNo, "Confirm Delete?") = vbYes Then
For I = 1 To DeletedQty
DoCmd.RunComman d acCmdDeleteReco rd *** Error Occurs Here ****
RunCommand acCmdSelectReco rd
Next I
MsgBox DeletedQty & " record(s) deleted!", vbOKOnly, "Record Deleted"
End If
Exit_cmdMultiDe leteRecord_Clic k:
DoCmd.DoMenuIte m acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.SetWarnin gs (WarningsOn)
NumberDeleted.V alue = Null
End Sub
Can somebody help me out and find out why it's not working?
Thanks,
Kevin
I got a multiple delete working here but for some reason I occassionally get this error. The way the delete works is there is a text box where the user enters the quantity to delete. If it is blank it will delete 1 item. It never fails when I delete just 1 item but if I delete more than one item it fails but only some times. Here is the error:
"Run-time error '2046':
The command or action 'DeleteRecord' isn't available now."
Here is my code:
Private Sub cmdMultiDeleteR ecord_Click()
Dim DeletedQty As Integer
If Me.Dirty Then Me.Dirty = False
DoCmd.SetWarnin gs (WarningsOff)
If Not IsNull(Me.Numbe rDeleted) Then
DeletedQty = Me.NumberDelete d
Else
DeletedQty = 1
End If
If MsgBox("Are you sure you want to delete " & DeletedQty & " record(s)?", vbQuestion + vbYesNo, "Confirm Delete?") = vbYes Then
For I = 1 To DeletedQty
DoCmd.RunComman d acCmdDeleteReco rd *** Error Occurs Here ****
RunCommand acCmdSelectReco rd
Next I
MsgBox DeletedQty & " record(s) deleted!", vbOKOnly, "Record Deleted"
End If
Exit_cmdMultiDe leteRecord_Clic k:
DoCmd.DoMenuIte m acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.SetWarnin gs (WarningsOn)
NumberDeleted.V alue = Null
End Sub
Can somebody help me out and find out why it's not working?
Thanks,
Kevin
Comment