# Linking Check Boxes To A Text Box

G

#### Guest

I have a text box (tapes) running from a query showing the values of
0,1,2,3,4 on a form, I have 4 check boxes, tape 1, tape 2, tape 3, tape 4.

I want the number in the text box to determine how many check boxes appear
on my form.

G

#### Guest

Create a looping function that enables or disables the checkboxes accordingly.

intNumChks = Me.Tapes
for i = 1 to intNumChks
Me("chkbox" & i).enabled = True
Next i
for j = intNumChks+1 to 4
Me("chkbox" & i).enabled = False
Next j

This is air code but should illustrates the principle.

Hope this helps,

Daniel P

J

#### John W. Vinson

I have a text box (tapes) running from a query showing the values of
0,1,2,3,4 on a form, I have 4 check boxes, tape 1, tape 2, tape 3, tape 4.

I want the number in the text box to determine how many check boxes appear
on my form.

ummmm....

Sounds like a pretty serious table design flaw, if these four textboxes are
bound to four non-normalized table fields! Someday you will need a FIFTH tape,
I'm guessing.

That said - you can use the Form's Current event to toggle the visibility of
the checkboxes. Assuming they are named chk1, chk2, chk3 and chk4, use code
like

Private Sub Form_Current()
Dim iChk As Integer
For iChk = 1 to 4
If NZ(Me.Tapes) < iChk Then
Me.Controls("chk" & iChk).Visible = (iChk <= NZ(Me.Tapes))
End If
Next iChk
End Sub

John W. Vinson [MVP]