I am writing a program in Access 2010. My check boxes are not saving to the table. I have stepped through the code with no errors and it only saves the last check box to the table. Here is my code:
I attached the full code.
Private Sub cmdSave_Click()
On Error GoTo cmdSave_Click_Error
Dim rs As Object
Dim db As Object
Set db = CurrentDb
Set rs = db.OpenRecordset("tblUserPermissions")
rs.AddNew
rs!FK_UserID = cboFullName.Value
rs!FK_UserRoleID = cboFK_UserRoleID.Value
If (chkAddManageEmployees.Value = True) And (chkEditManageEmployees.Value = False) And (chkDeleteManageEmployees.Value = False) And (chkViewManageEmployees.Value = False) Then
rs!FormName = "ManageEmployees"
rs!Allowed = "Add"
Else
rs!FormName = "ManageEmployees"
rs!Allowed = "None"
End If
If (chkAddManageEmployees.Value = True) And (chkEditManageEmployees.Value = True) And (chkDeleteManageEmployees.Value = True) And (chkViewManageEmployees.Value = True) Then
rs!FormName = "ManageEmployees"
rs!Allowed = "Edit"
Else
rs!FormName = "ManageEmployees"
rs!Allowed = "None"
End If
.......
If chkViewFenceTypes.Value = True Then
rs!FormName = "FenceTypes"
rs!Allowed = "View"
Else
rs!FormName = "FenceTypes"
rs!Allowed = "None"
End If
If chkViewMaterialTypes.Value = True Then
rs!FormName = "MaterialTypes"
rs!Allowed = "View"
Else
rs!FormName = "MaterialTypes"
rs!Allowed = "None"
End If
If chkViewIdentificationTypes.Value = True Then
rs!FormName = "IdentificationTypes"
rs!Allowed = "View"
Else
rs!FormName = "IdentificationTypes"
rs!Allowed = "None"
End If
If chkViewInstallationTeams.Value = True Then
rs!FormName = "InstallationTeams"
rs!Allowed = "View"
Else
rs!FormName = "InstallationTeams"
rs!Allowed = "None"
End If
rs.Update
Exit Sub
cmdSave_Click_Exit:
rs.Close
Set rs = Nothing
db.Close
Exit Sub
cmdSave_Click_Error:
MsgBox "Error #:" & Err.Number & vbCrLf & "Error Description: " & Err.Description, vbOKCancel, "User Permissions: Duplicate values not allowed!"
Resume cmdSave_Click_Exit
End Sub
I attached the full code.