controls and variable

  • Thread starter Thread starter Squibbly2
  • Start date Start date
S

Squibbly2

is it possible to set a control as a variable e.g.

example=Me!controlName.Visible

if so is that a correct example?
 
i have tried this but it doesnt work how would i set a control to a variable
so i dont need to keep retyping this out
 
dont worry i found out how to do it

its like this

Set xxx=Me!ControlName
xxx.Visible=True
 
Yes, the Set is necessary when assigning an object (as
opposed to a value) to a variable.

But, in addition, you should be concerned with how the
object variable is declared. You can Dim the object
variable as a Variant, but that is the most inefficient way
and does not provide any meaningful error checking. [Note
that you should **always** declare your variables and to
enforce that rule, make sure you have an OPTION EXPLICIT
statement in **all** your modules.]

When you do not know what kind of control you will be
assigning to the variable, you should use:
Dim xxx As Control
but, when you do know the control type, then use the
specific type, e.g.
Dim xxx As TextBox
 
ok thanks for the advice

Marshall Barton said:
Yes, the Set is necessary when assigning an object (as
opposed to a value) to a variable.

But, in addition, you should be concerned with how the
object variable is declared. You can Dim the object
variable as a Variant, but that is the most inefficient way
and does not provide any meaningful error checking. [Note
that you should **always** declare your variables and to
enforce that rule, make sure you have an OPTION EXPLICIT
statement in **all** your modules.]

When you do not know what kind of control you will be
assigning to the variable, you should use:
Dim xxx As Control
but, when you do know the control type, then use the
specific type, e.g.
Dim xxx As TextBox
--
Marsh
MVP [MS Access]

dont worry i found out how to do it

Set xxx=Me!ControlName
xxx.Visible=True
 
Back
Top