When I run this code to delete the form's current record, the Me.Requery throws error #3167 (Record is deleted) and leaves "#Deleted" in all of the fields. Any thoughts? Thanks in advance.
Patrick
=========================
Private Sub DeleteProfessional_Click()
Dim MyDatabase As Database
Dim rstProfessionals As DAO.Recordset
Set rstProfessionals = Form_Professional.RecordsetClone
If (rstProfessionals.RecordCount = 0) Then
MsgBox ("There are no Professionals to delete!")
Exit Sub
End If
Confirm = MsgBox("Delete the current professional?", vbYesNo)
If (Confirm = vbYes) Then
' Warn if current professional is lead
If ProfessionalLead.Value = True Then
Continue = MsgBox("You are about to delete the current lead professional." & vbNewLine & _
"Continue?", vbYesNo + vbExclamation)
If (Continue = vbNo) Then
Exit Sub
End If
End If
' Delete the current record
SqlStr = "DELETE * FROM Professional Where ID = " & Me.ID
Set MyDatabase = CurrentDb
MyDatabase.Execute SqlStr
' Refresh the form data
Me.Requery
End If
End Sub
Patrick
=========================
Private Sub DeleteProfessional_Click()
Dim MyDatabase As Database
Dim rstProfessionals As DAO.Recordset
Set rstProfessionals = Form_Professional.RecordsetClone
If (rstProfessionals.RecordCount = 0) Then
MsgBox ("There are no Professionals to delete!")
Exit Sub
End If
Confirm = MsgBox("Delete the current professional?", vbYesNo)
If (Confirm = vbYes) Then
' Warn if current professional is lead
If ProfessionalLead.Value = True Then
Continue = MsgBox("You are about to delete the current lead professional." & vbNewLine & _
"Continue?", vbYesNo + vbExclamation)
If (Continue = vbNo) Then
Exit Sub
End If
End If
' Delete the current record
SqlStr = "DELETE * FROM Professional Where ID = " & Me.ID
Set MyDatabase = CurrentDb
MyDatabase.Execute SqlStr
' Refresh the form data
Me.Requery
End If
End Sub
Last edited: