Calculated values used in naming

Eikenhorst

Registered User.
Local time
Today, 05:18
Joined
Mar 9, 2007
Messages
25
Hello,

I have a problem with VBA. I have a form with a lot of textboxes. I only want to display the amount of textboxes as divined in a table. So if the value in the table is 4, I only want it to show the first 4 values, but if it is 99 then I want it to show the first 99 textboxes.

Since I don’t want to work with a huge amount of If statements I would like to work with some sort of flexible naming. Those textboxes are named Text1 to Text100 So I made the following Code:
Dim CurrNumber As Byte
CurrNumber = 1
Do Until CurrNumber = rst![Value1] + 1
Me.Text[CurrNumber].Visible = True
CurrNumber = CurrNumber + 1
Loop

But I don’t know how I should get the “Me.Text[CurrNumber].Visible = True” line right. Could someone please help me a hand with this one? Any help is greatly appreciated! Thanks!
 
Me.Controls("Text" & CurrNumber).Visible = True
 
Thanks! _0_ That was just what I was looking for! You're my hero for today :D
 
I have another small question bassed on the last one. Is it also posible to hide ALL opbjects on my form.

So something like this:
Me.Controls(*).Visible = False
Ofcourse this doesn't work, but is there a simple way to do something like this?

Thanks
 
Code:
Dim i as Integer

For i=0 to me.Controls.Count-1
     Me.Controls(i).Visible = False
Next i
 

Users who are viewing this thread

Back
Top Bottom