Set visible property (basic)

herby_one

Registered User.
Local time
Today, 07:39
Joined
Sep 30, 2004
Messages
22
Hi,
I'm trying to set several fields to a false visible property when an option is selcted in a combo box.
Does anyone know how to use a variable in a loop to set the visible property to false.
This is the code I'm using, the line in bold being the problem.
thanks in advance.

Private Sub Landlord_Type_Change()
Dim labelC As Integer
Dim counter As Integer
Dim current, property

counter = 0
labelC = 97 'Label counter

Do Until counter = 10
current = "Label" & labelC
Set property = current
property.Visible = False

counter = counter + 1
labelC = labelC + 1
Loop
 
Not too sure but I would be inclined to see if you can move to a Me format.
The usual sort of thing is Me.txtLandlord.Visible = True
I do not know if it would work with Me.current.Visible = True but it might be worth trying
Good luck
 
Why are youstarting at 97?
 
What's about

Code:
Controls(current).Visible = False

?

Agnostiker
 
Last edited:
Agnostiker said:
What's about

Code:
Controls(current).Visible = False

?

That is sort of what I was getting to. I have the belief that herby-one has just used the default names that Access gives to controls rather than name them for him/herself meaning that there are ten controls such as Text97 through Text106 that are required to be made invisible.

Were this the case, rather than use the Controls method as you have used I'd use the Me method as the default value of the Me Class is the controls.

ie..

Code:
Dim intCounter As Integer
For intCounter = 1 To 10
    Me("Text" & 96 + intCounter).Visible = False
Next intCounter
 
Thank you!!!

Worked perfectly - thanks, appreciate it.

(Started at no 97 simply cause that was the number of the first label and couldn't be bothered going through and changing them all).
 
Sorry,

I omit the "Me" cause I didn't know from where he'll launch that loop.
But with that "Me" (Me.Controls(current*).Visible = False) it is purely the same reference as you've used, isn't it?

*that "current" in his exampel


Greetings from Berlin

Agnostiker
 
Agnostiker said:
But with that "Me" (Me.Controls(current*).Visible = False) it is purely the same reference as you've used, isn't it?

*that "current" in his exampel

Yep. Me makes it more compiler friendly. :)
 

Users who are viewing this thread

Back
Top Bottom