A2003 on Win XP
I have a form with a subform. The form contains one main record, the subform contains all detail records related to the main record. The subform is displayed as continuous forms, as I need to have 2 buttons for each detail record: an edit button which takes me to a screen to edit the detail record, and a delete button to delete only that one detail record.
When I click the delete button on an existing record on the subform, I get this error:
This subform was copied from another subform where the delete button works just fine. I looked for misspelled event names, but could not find any problems.
Any idea what may be causing the error?
Thanks.
EDIT: Here is my code, but my code is never executed so I cannot set a breakpoint in it.
I have a form with a subform. The form contains one main record, the subform contains all detail records related to the main record. The subform is displayed as continuous forms, as I need to have 2 buttons for each detail record: an edit button which takes me to a screen to edit the detail record, and a delete button to delete only that one detail record.
When I click the delete button on an existing record on the subform, I get this error:
This error happens before I even enter the delete button event code, so I cannot set a breakpoint inside the delete button code. The error happens before the code is executed inside the delete button.The expression On Click you entered as the event property setting produced the following error: A problem occurred while MS Access was communicating with the OLE server or ActiveX control.
* The expression may not result in the name of a macro, the name of a user-defined function, or [event procedure].
* There may have been an error evaluating the function, event, or macro.
This subform was copied from another subform where the delete button works just fine. I looked for misspelled event names, but could not find any problems.
Any idea what may be causing the error?
Thanks.
EDIT: Here is my code, but my code is never executed so I cannot set a breakpoint in it.
Code:
Private Sub cmdDeleteDetailVend_Click()
Dim procname As String
Dim crit As String
Dim myID As Long
On Error GoTo Err_cmdDeleteVend_Click
Dim i As Integer
procname = "cmdDeleteDetailVend"
i = MsgBox("Are you sure you want to delete this?", vbYesNo)
If i = vbYes Then
myID = txtPDVIDsubf.Value
DoCmd.SetWarnings False
DoCmd.Hourglass True
crit = "DELETE FROM ProjectDetailVendors WHERE [PDVID]=" & myID
crit = crit & ";"
DoCmd.RunSQL crit
DoCmd.SetWarnings True
'Forms("ProjectEdit")!subfDetails.Requery
DoEvents
Me.Requery ' Requery subform.
End If
Exit_cmdDeleteDetailVend_Click:
DoCmd.Hourglass False
Exit Sub
Err_cmdDeleteDetailVend_Click:
If Err.Number = 2046 Then ' we're at beginning of recordset, and got error on Previous.
DoCmd.Hourglass False
'Exit Sub
Resume Next
Else
Call DispError(procname)
DoCmd.Hourglass False
Resume Exit_cmdDeleteDetailVend_Click
End If
End Sub
Last edited: