Concatenation for control name

Phonik

Registered User.
Local time
Today, 02:41
Joined
Sep 22, 2006
Messages
111
Hi all

Is it possible to use a variable to finish the name of a control?

e.g.

Cell = me.A1 (where A1 is a lablel with the name a1)

forms![Myform]! "Cell".forecolor = 65280

What I am basically trying to do is to have a variating control name that i can change the color of.....too long to explain why really.

Can anyone help me please....is this possible?

Thanks
 
Code:
Me.Controls("ControlName").[i]Property[/i] = [i]Value[/i]
 
Thanks for your reply. Im not 100% sure that I can do what I want to with that but I will certainly try...

If anyone else has any other suggestions I would be very grateful.

Thanks

Gareth
 
Hi

What happens if I am writing the code in a module and I cant use the ME.??

Thanks
 
Code:
Forms![i]FormName[/i].Controls("ControlName").[i]Property[/i] = [i]Value[/i]

Or:

Code:
Forms.("FormName").Controls("ControlName").[i]Property[/i] = [i]Value[/i]
But not:
Code:
Forms!FormName!ControlName.[i]Property[/i] = [i]Value[/i]
...if you are using variables in the construction.
 
Thanks again..

So where you have writted (ControlName) do I just replace this with variable? DO I need to use the & symbol?

I really appreciate you helping me out...
 
I have just managed to get it to work!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

You have no idea how much time you have just saved me!! Thank you so much!!!!
 
there is also an active screen, and active control which you can use directly

so use the control gotfocus and lostfocus events with a function call to a modular function

specifiy the gotfocus event as
=highlight()

and the lost focus event as
=lowlight

then your function

is just

function highlight
{or whatever}
screen.activecontrol.backcolor=vbwhite

end function

and you dont need to worry about your form name etc
 
there is also an active screen, and active control which you can use directly

so use the control gotfocus and lostfocus events with a function call to a modular function

specifiy the gotfocus event as
=highlight()

and the lost focus event as
=lowlight()

{the syntax is just that - needs the = and the () to work}

then your function

is just

function highlight
{or whatever}
screen.activecontrol.backcolor=vbwhite

end function

and you dont need to worry about your form name etc
 

Users who are viewing this thread

Back
Top Bottom