Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display field as check box

Status
Not open for further replies.

zrobinso

MIS
Apr 22, 2001
27
0
0
US
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top