When I delete the last record on a subform, it deletes the record but I get the following error:
2465
Access can't find the field "|" referred to in your expression.
And if I delete the only record on a subform, it deletes the record but I get the following error:
2185
You can't reference a property or method for a control unless the control has the focus.
Here's the code behind my Delete button:
If I comment out the "On error goto GotError" line, it goes to the "DoCmd.RunCommand acCmdDeleteRecord" line.
It's probably something very simple but I'm just not seeing it.
Thanks,
Debbie
2465
Access can't find the field "|" referred to in your expression.
And if I delete the only record on a subform, it deletes the record but I get the following error:
2185
You can't reference a property or method for a control unless the control has the focus.
Here's the code behind my Delete button:
Code:
Private Sub cmdDelete_Click()
On Error GoTo GotError
If Not Me.NewRecord And Me.Dirty Then
CompleteMsg
Exit Sub
End If
msg1 = "You are about to delete "
msg2 = Me.Parent!Employee_combo.Column(1)
msg3 = "Date: " & Me.WorkDate & ", Temp Dept: " & Me.TempDept & ", Reg Hrs: " & Me.TempDeptRegHrs & ", O/T Hrs: " & Me.TempDeptOTHrs
msg4 = "Are you sure you want to do this? You will not be able to undo if you choose Yes."
style = vbCritical + vbYesNo + vbDefaultButton2
Response = MsgBox(msg1 & msg2 & vbCrLf & msg3 & vbCrLf & vbCrLf & msg4, style, conTitle)
If Response = vbYes Then
Me.AllowDeletions = True
DoCmd.SetWarnings False 'turn system messages off
DoCmd.RunCommand acCmdDeleteRecord
DoCmd.SetWarnings True 'turn system messages on
Me.AllowDeletions = False
Me.cmdAdd.SetFocus
End If
ExitSub:
Exit Sub
GotError:
If Err.Number = 2046 Then Resume ExitSub
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf & "cmdDelete"
Resume ExitSub
End Sub
If I comment out the "On error goto GotError" line, it goes to the "DoCmd.RunCommand acCmdDeleteRecord" line.
It's probably something very simple but I'm just not seeing it.
Thanks,
Debbie