Is it possible to reference a field caption via VBA? I have a series of checkboxes with captions that I would like to compile into 3 different text boxes. Sample output would be similar to "Academic, Public, Special" when the options are Academic, Government, Public, and Special. There may be an easier way to do this, but for now, since I want three sets of checkboxes output the same way, I thought to write one procedure:
Now, I'm used to working with forms, not reports, so some of my declarations may be off. Then again, maybe I just can't refer to the Caption property of a field (though the documentation points to the fact that I can).
The specific error I get is a "Method or Data member not found" on the CheckList = ctlField.Caption line.
Any thoughts? TIA
Code:
Dim ctlFieldsArray As Variant, i As Variant, db As Database, rst As DAO.Recordset, ctlField As Field
Set db = CurrentDb
Set rst = db.OpenRecordset("tblProjects", dbOpenDynaset)
CheckList = ""
Select Case ListType
Case "Benetype"
ctlFieldsArray = Array("projBeneTypeAcad", "projBeneTypePub", "projBeneTypeSchool", "projBeneTypeSpec", "projBeneTypeOther")
Case "Bene"
ctlFieldsArray = Array("projBeneLibStaff") ', rst![projBeneLibUsers], rst![projBeneSpecific], rst![projBeneOther])
Case "Activities"
ctlFieldsArray = Array("projActStaffTraining") ', rst![projActUserTraining], rst![projActGrants], rst![proActDev], rst![proActDemo], rst![proActOther], rst![proActDetail])
End Select
For Each i In ctlFieldsArray
Set ctlField = rst.Fields(i)
If ctlField = True Then
If CheckList = "" Then
CheckList = ctlField.Caption
Else
CheckList = "; " & ctlField.Caption
End If
End If
Next i
rst.Close
db.Close
Now, I'm used to working with forms, not reports, so some of my declarations may be off. Then again, maybe I just can't refer to the Caption property of a field (though the documentation points to the fact that I can).
The specific error I get is a "Method or Data member not found" on the CheckList = ctlField.Caption line.
Any thoughts? TIA