make number of fields visible based on 1 field value ?

amanco

Registered User.
Local time
Today, 21:26
Joined
May 10, 2004
Messages
53
i have a field with a dropdown menu of 0-10

i would like to do this:

if i choose 3 for example, i get Field1, Field2 and Field3 to be "visible" in the form.

i am trying to use the IIF statement but with no luck so far. can someone help me please? thanks
 
ok it's working now

Code:
Private Sub MyDropDownBox_AfterUpdate()
If Me.Mytextbox = 8 Then
        Me.Mytextbox.Visible = True
    Else
        Me.Mytextbox.Visible = False
    End If
End Sub

but is there a trick to write less code for a mass of visible txtboxes.


thanks :)
 
Last edited:
___ said:

thank you HTH :D

i used this now:

Code:
Me.Brother1.Visible = IIf(Me.BrotherS >= 1, True, False)
Me.Brother2.Visible = IIf(Me.BrotherS >= 2, True, False)
Me.Brother3.Visible = IIf(Me.BrotherS >= 3, True, False)
Me.Brother4.Visible = IIf(Me.BrotherS >= 4, True, False)
Me.Brother5.Visible = IIf(Me.BrotherS >= 5, True, False)
Me.Brother6.Visible = IIf(Me.BrotherS >= 6, True, False)
Me.Brother7.Visible = IIf(Me.BrotherS >= 7, True, False)
Me.Brother8.Visible = IIf(Me.BrotherS >= 8, True, False)
Me.Brother9.Visible = IIf(Me.BrotherS >= 9, True, False)
Me.Brother10.Visible = IIf(Me.BrotherS >= 10, True, False)

but i couldnt make it in the short form like what Mile-O-Phile did.
 
Simplified:

Code:
Dim intCounter As Integer
For intCounter = 1 To 10
    Me("Brother" & intCounter).Visible = IIf(Me.BrotherS >= intCounter, True, False)
Next intCounter
 
Mile-O-Phile said:
Simplified:

Code:
Dim intCounter As Integer
For intCounter = 1 To 10
    Me("Brother" & intCounter).Visible = IIf(Me.BrotherS >= intCounter, True, False)
Next intCounter


working like a charm, thank you :D
 

Users who are viewing this thread

Back
Top Bottom