Variable in a Variable

CPGDeveloper

Board Regular
Joined
Oct 8, 2008
Messages
174
Hi All,

I don't know if this is possible, but I have a subroutine that populates the caption of a label. Something like this:

Forms!Form1!LabelTitle.Caption = titlevariable

'titlevariable' is defined by looking up the value in a table, and if the value in the table is a simple string, such as 'MANAGER', it works fine.

However, what if instead of passing the string 'MANAGER', I want to pass another variable.

So for example, if titlevariable = "anothervariable", which is also a variable. And anothervariable = "MANAGER"

In this scenario, is there a way I can write
Forms!Form1!LabelTitle.Caption = titlevariable, so that the caption of this label ends up being 'MANAGER' as opposed to 'another variable'?
 
The variable in the situation I'm working through is a public variable, that has been declared and defined upon the application opening. And the value of that variable is different depending on who the user of the application is -- I was just trying to see if I could avoid some hard coding, but point taken -- this doesn't seem possible. Thanks for your time.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
The only way I can envision getting around it would be to use the variable name as a PK field value as long as the needed value could be looked up from another field in that table. However, that would make no sense if the needed value was static as it might as well be like all the other records you have. If the needed value could be anything at run time, then I suppose the answer would be to update the current needed value that's related to the PK, then use it. e.g.
during run time, before value is retrieved:
ID/Title
1/Manager
2/Developer
3/CEO
4/strAnalyst

after new value is determined
ID/Title
1/Manager
2/Developer
3/CEO
4/SomethingElse
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top