kristi1023
Programmer
Hi,
I have 20 unbound checkboxes on a subform and I'd like to update a separate table with employee id and skill id. I'm using the following code on_click event of a button:
If Me.Check1 = True Then
[SkillID] = 1
DoCmd.SetWarnings False
DoCmd.RunSQL "insert into tblskillassessment employeeid,skillid) values (employeeid, [skillid])"
DoCmd.SetWarnings True
Else
DoCmd.SetWarnings False
DoCmd.RunSQL "delete from tblskillassessment where (((tblSkillAssessment.SkillID)=1) AND ((tblSkillAssessment.EmployeeID)=[Forms]![frmEmployeeSkills1]![EmployeeID]))"
DoCmd.SetWarnings True
End If
-----------------------------------------
I run the above code for each checkbox and update the where (((tblSkillAssessment.SkillID)=x)based upon the checkbox .
It works, but it's not 100% reliable; I'm getting duplicate records and the error message: Record is Deleted.
Is there a better way of adding and deleting records based upon a checkbox being checked or unchecked?
THANKS!
I have 20 unbound checkboxes on a subform and I'd like to update a separate table with employee id and skill id. I'm using the following code on_click event of a button:
If Me.Check1 = True Then
[SkillID] = 1
DoCmd.SetWarnings False
DoCmd.RunSQL "insert into tblskillassessment employeeid,skillid) values (employeeid, [skillid])"
DoCmd.SetWarnings True
Else
DoCmd.SetWarnings False
DoCmd.RunSQL "delete from tblskillassessment where (((tblSkillAssessment.SkillID)=1) AND ((tblSkillAssessment.EmployeeID)=[Forms]![frmEmployeeSkills1]![EmployeeID]))"
DoCmd.SetWarnings True
End If
-----------------------------------------
I run the above code for each checkbox and update the where (((tblSkillAssessment.SkillID)=x)based upon the checkbox .
It works, but it's not 100% reliable; I'm getting duplicate records and the error message: Record is Deleted.
Is there a better way of adding and deleting records based upon a checkbox being checked or unchecked?
THANKS!