Variable to Label (1 Viewer)

mark curtis

Registered User.
Local time
Today, 14:31
Joined
Oct 9, 2000
Messages
457
Hi folks,

In code i have built a string variable called strRAG which is a combination of text "Me!lbl" and another variable called intSiteID, which forms for example label name Me!lbl51.

I have a form with loads of labels on it and what i want to do is use this string to set the BackColor of the label.

The code i use loops round building up different label names but i am have problems relating the strRAG detail to the form labels.

I have posted this question in VBA early this week but after looking at the wording i have tried to rephrase it.

Thanks
Mark
 

Pauldohert

Something in here
Local time
Today, 06:31
Joined
Apr 6, 2004
Messages
2,101
I don't quite know what you are trying to do but

Me("lbl" & intSiteID).BackColor = vbRed
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 08:31
Joined
Feb 28, 2001
Messages
27,389
Paul, don't you need it to be

Me.Controls("lbl"&CStr(intSiteID))

?
 

Pauldohert

Something in here
Local time
Today, 06:31
Joined
Apr 6, 2004
Messages
2,101
The above works fine for me.


I both explicitly had intSiteID as integer or long and left it as a variant - any way it worked ok.


Changed to your suggestion too DocMan and that works also.
 
Last edited:

Users who are viewing this thread

Top Bottom