Hello,
I have a form (form_student) with student's information where I want to create a button with "on click" event and it should delete the record of this student from my table (that's called tb_student).
Snippet of my code
Form_class is a subform in my current form_student. This student is assigned to a class, so after deleting this student it should delete also from the tb_class.
The problem is when I've tried to delete a student, this error came up.
Can somebody explain what this error means and how to fix it?
Thank you
I have a form (form_student) with student's information where I want to create a button with "on click" event and it should delete the record of this student from my table (that's called tb_student).
Snippet of my code
Code:
If MsgBox("Delete this student?", vbYesNo + vbCritical + vbDefaultButton2, "Warning") = vbYes Then
If Me.Dirty Then
Me.Undo
End If
CurrentDb.Execute _
"DELETE FROM tb_student " & _
"WHERE ID = " & Me.ID
If Not IsNull(Me.form_class!IDclass) Then
CurrentDb.Execute _
"DELETE FROM tb_class " & _
"WHERE IDclass = " & Me.form_class!IDclass
End If
MsgBox "Deleted!"
DoCmd.Close acForm, "form_student", acSavePrompt
End If
Form_class is a subform in my current form_student. This student is assigned to a class, so after deleting this student it should delete also from the tb_class.
The problem is when I've tried to delete a student, this error came up.
Can somebody explain what this error means and how to fix it?
Thank you