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.
Daniel - 24 Mar 2007 17:30 GMT
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
> 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.
John W. Vinson - 24 Mar 2007 18:15 GMT
>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]