I have an Entry form that writes the control names of unbound check boxes to one field [svcResult]in a table [tbl_serviceResponse].
Each record is linked by responseID (many)to Services Table (one).
How can I reverse this to display the boxes as checked if the user needs to edit the record (Delete check or append more by ID#)? I am using the following code:
Private Sub closefrm_Click()
DoCmd.RunCommand acCmdSaveRecord
On Error GoTo Err_cmdAddNew_Click
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim frm As Form
Dim ctl As Control
Set dbs = currentdb
Set rst = dbs.OpenRecordset("tbl_ServiceResponse", dbOpenDynaset)
Set frm = Screen.ActiveForm
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acCheckBox
If ctl.Value = True Then
With rst
.AddNew
![ResponseID] = Me.ResponseID
![SvcResult] = ctl.Name
.Update
End With
End If
End Select
Next ctl
MsgBox "Answers added to database.", vbOKOnly + vbInformation, "Answers Update"
rst.close
DoCmd.close
Exit_cmdAddNew_Click:
Exit Sub
Err_cmdAddNew_Click:
MsgBox Err.Description
Resume Exit_cmdAddNew_Click
End Sub
Each record is linked by responseID (many)to Services Table (one).
How can I reverse this to display the boxes as checked if the user needs to edit the record (Delete check or append more by ID#)? I am using the following code:
Private Sub closefrm_Click()
DoCmd.RunCommand acCmdSaveRecord
On Error GoTo Err_cmdAddNew_Click
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim frm As Form
Dim ctl As Control
Set dbs = currentdb
Set rst = dbs.OpenRecordset("tbl_ServiceResponse", dbOpenDynaset)
Set frm = Screen.ActiveForm
For Each ctl In frm.Controls
Select Case ctl.ControlType
Case acCheckBox
If ctl.Value = True Then
With rst
.AddNew
![ResponseID] = Me.ResponseID
![SvcResult] = ctl.Name
.Update
End With
End If
End Select
Next ctl
MsgBox "Answers added to database.", vbOKOnly + vbInformation, "Answers Update"
rst.close
DoCmd.close
Exit_cmdAddNew_Click:
Exit Sub
Err_cmdAddNew_Click:
MsgBox Err.Description
Resume Exit_cmdAddNew_Click
End Sub