B
Beedrew
Guest
Hi Everyone,
I am new to Access. I have a tabular form showing multiple records, and I want to have a delete button on the form to delete the currently selected record. This should be very simple using the Command button wizard, which generates the following on the onClick event of my button:
Private Sub DeleteWizard_Click()
On Error GoTo Err_DeleteWizard_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteWizard_Click:
Exit Sub
Err_DeleteWizard_Click:
MsgBox Err.Description
Resume Exit_DeleteWizard_Click
End Sub
But when I run the form and click the button to delete a selected record, the record IS deleted but then an error message pops up:
You entered an expression that has an invalid reference to property |.
(Not a typo -- it really looks like the stovepipe in the message).
I have tried replacing the two "DoCmd" lines with the following, which I read was a newer way to activate menu commands:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
But I get the same error message.
I tried using a macro with the RunCommand / DeleteRecord line, but it works the same way -- deletes the record, but throws an "Action Failed" message that I have to delete.
I got into the debugger a bit by remarking out the error handling in the code above, and it identified the above as run-time error 2455 and flagged the second "DoCmd" line, which actually deletes the record, as the problem (of course!)
I thought of writing a delete query but I did not know how to write one that would not have criteria, but would instead reference the currently selected record in the form.
I am running Access 2002 SP3. Any help would be so very much appreciated, because this simple little task has eaten up hours!
Cheers,
Bee
I am new to Access. I have a tabular form showing multiple records, and I want to have a delete button on the form to delete the currently selected record. This should be very simple using the Command button wizard, which generates the following on the onClick event of my button:
Private Sub DeleteWizard_Click()
On Error GoTo Err_DeleteWizard_Click
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
Exit_DeleteWizard_Click:
Exit Sub
Err_DeleteWizard_Click:
MsgBox Err.Description
Resume Exit_DeleteWizard_Click
End Sub
But when I run the form and click the button to delete a selected record, the record IS deleted but then an error message pops up:
You entered an expression that has an invalid reference to property |.
(Not a typo -- it really looks like the stovepipe in the message).
I have tried replacing the two "DoCmd" lines with the following, which I read was a newer way to activate menu commands:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
But I get the same error message.
I tried using a macro with the RunCommand / DeleteRecord line, but it works the same way -- deletes the record, but throws an "Action Failed" message that I have to delete.
I got into the debugger a bit by remarking out the error handling in the code above, and it identified the above as run-time error 2455 and flagged the second "DoCmd" line, which actually deletes the record, as the problem (of course!)
I thought of writing a delete query but I did not know how to write one that would not have criteria, but would instead reference the currently selected record in the form.
I am running Access 2002 SP3. Any help would be so very much appreciated, because this simple little task has eaten up hours!
Cheers,
Bee