T
Tim Peters
I have a form and subform combination for entering two related records, an
Inventory item Master definition and an Inventory item sub definition. The
master information is on the main form and the sub definition is on the
subform. I have coded logic to delete the master record that is
automatically written by Access when the user tabs from the main form into
the subform IN THE EVENT that the user enters no information into the subform
and exits from/closes the main form using the exit button I've provided.
When I test this code, I get error 2046 "The command or action
acCmdDeleteRecord isn't available now." and I cannot figure out why I am
getting this error. My code to do this delete, which is in the click event
of my main form's Exit button, is:
Private Sub cmdExitInvMaster_Click()
On Error GoTo Err_cmdExitInvMaster_Click
'If Hardware specific record (i.e PC, Router, etc.) not created and Inv
Class is Hardware, delete Inv Master
If Not HWMasterExists And IMInvClassID = 1 Then
Me.IMInvDescr.SetFocus
DoCmd.RunCommand acCmdDeleteRecord
End If
DoCmd.Close
Exit_cmdExitInvMaster_Click:
Exit Sub
Err_cmdExitInvMaster_Click:
MsgBox Err.Description
Resume Exit_cmdExitInvMaster_Click
End Sub
Note: HWMasterExists is a function that tests to see if a record was created
in the subform, and seems to be working fine. Record source for main form is
a query over the associate InventoryMaster table. Please pardon if this is
posted twice -my first posting, and having a bit of difficulty getting the
hang of it. Any help will be greatly appreciated.
Inventory item Master definition and an Inventory item sub definition. The
master information is on the main form and the sub definition is on the
subform. I have coded logic to delete the master record that is
automatically written by Access when the user tabs from the main form into
the subform IN THE EVENT that the user enters no information into the subform
and exits from/closes the main form using the exit button I've provided.
When I test this code, I get error 2046 "The command or action
acCmdDeleteRecord isn't available now." and I cannot figure out why I am
getting this error. My code to do this delete, which is in the click event
of my main form's Exit button, is:
Private Sub cmdExitInvMaster_Click()
On Error GoTo Err_cmdExitInvMaster_Click
'If Hardware specific record (i.e PC, Router, etc.) not created and Inv
Class is Hardware, delete Inv Master
If Not HWMasterExists And IMInvClassID = 1 Then
Me.IMInvDescr.SetFocus
DoCmd.RunCommand acCmdDeleteRecord
End If
DoCmd.Close
Exit_cmdExitInvMaster_Click:
Exit Sub
Err_cmdExitInvMaster_Click:
MsgBox Err.Description
Resume Exit_cmdExitInvMaster_Click
End Sub
Note: HWMasterExists is a function that tests to see if a record was created
in the subform, and seems to be working fine. Record source for main form is
a query over the associate InventoryMaster table. Please pardon if this is
posted twice -my first posting, and having a bit of difficulty getting the
hang of it. Any help will be greatly appreciated.