variable controls???? HELP

tomro1

Registered User.
Local time
Tomorrow, 00:18
Joined
Jun 12, 2006
Messages
23
ok, is there a was to put into a string or field the name of a control that is on your form, like a label, and then summon that name from the string and set it as a control in your code, like this but then in a way that works:

dim str as string
private sub button1_click()
dim ctl as control

str = "label1"
set ctl = str.name
ctl.caption = "works"

end sub

now this is just an example, but does anyone know in what way this is possible?
 
"set it as a control in your code" - Can you please describe what you want your function to do? I, at least, need a bit more info..
 
Be careful with your declarations. Str is a function, and therefore shouldn't be used as variable name.

Dim TheControlName as string
Dim ctl as Access.Control
TheControlName = "lblMyLabel"
set ctl = me.controls(TheControlName)
ctl.caption = "whatever"
set ctl = nothing
 
I'm re writing it !!!!
 
Last edited:
thanks RoyVidar, the code works perfect.
It was all in the me.controls(***)
 

Users who are viewing this thread

Back
Top Bottom