boblarson
Smeghead
- Local time
- Yesterday, 16:38
- Joined
- Jan 12, 2001
- Messages
- 32,059
Okay, your main problem is that you didn't have the underscore within the ref_ID field name. Changed the code to this:
One problem I noticed is that after the deletion the form won't requery because your form is based off a temp table but the load of it is based on the permanent table. Somehow you need to run the code for the button on the main form.
Also, you are using DoCmd.SetWarnings and, for one - it is DoCmd.SetWarnings FALSE (not OFF) and then if you do use those you need to put DoCmd.SetWarnings TRUE as the first line in your Error Handler as well so that you don't end up with no warnings at all if the code errors out and you don't get to the reset code.
Code:
Dim Sql As String
If Me.Check26.OldValue = True Then
Sql = "Delete from tblreferences where refid=" & Me.ID & "And qcpid=" & Me.txtreferences
DoCmd.RunSQL Sql
End If
Exit Sub
One problem I noticed is that after the deletion the form won't requery because your form is based off a temp table but the load of it is based on the permanent table. Somehow you need to run the code for the button on the main form.
Also, you are using DoCmd.SetWarnings and, for one - it is DoCmd.SetWarnings FALSE (not OFF) and then if you do use those you need to put DoCmd.SetWarnings TRUE as the first line in your Error Handler as well so that you don't end up with no warnings at all if the code errors out and you don't get to the reset code.