I've found a couple solutions to achieve my goal, but cannot get any to actually work. Any help is appreciated.
Goal: I have a form i'm using to view summary data - we'll call this form1. On form1, the user will choose a record from table1 and see other fields from table1. In table2, I store information related to each table1 record using several checkbox fields. For each record in table1, I'd like to display the caption of each checked checkbox in table2 on form1.
Method 1 - DLookUp
I built a query (query1) that essentially sums the text of the checked fields (checkedfields1). Formatting of the text isn't real clean but it could get the job done. I set the text box control source to checkedfield1 from query1. The result appears to work a little bit, but i think what i'm missing is limiting the result to a single row that matches the current record on form1.
Method 2 - VB script
I'm a novice with VB but can figure it out here and there. I tried messing around with this, to no avail:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Dim topVal1 As Long
Dim leftVal0 As Long
Dim leftVal1 As Long
'Set first row values
topVal1 = 0
leftVal0 = 0
leftVal1 = 1500
'Loop through each control and determine visibility and position
Dim ctl As Control
Dim labelname As String
Dim lastitem As String
For Each ctl In Me.Controls
If ctl.ControlType = acCheckBox Then
labelname = "lbl" & ctl.Name 'Get label name from checkbox name (ensure labels are named lblcheckboxname)
If ctl.Value = True Then
'Show label and set position
Controls(labelname).Visible = False
lastitem = lastitem & Controls(labelname).Caption & ", "
Else
'Hide fields, position not important
Controls(labelname).Visible = False
End If
End If
Next ctl
If lastitem = "" Then
Me.txtallitems = " "
Me.txtallitems.Visible = True
Me.txtallitems.Left = leftVal1
Me.txtallitems.Top = topVal1
Else
lastitem = Left(lastitem, Len(lastitem) - 2)
Me.txtallitems = lastitem
Me.txtallitems.Visible = True
Me.txtallitems.Left = leftVal1
Me.txtallitems.Top = topVal1
End If
End Sub