Text box Forecolor change

Curry

Registered User.
Local time
Tomorrow, 05:10
Joined
Jul 21, 2003
Messages
73
Him All,

I am trying to change the forecolor of multiple text boxes after the selection of one or many of these text boxes listed in a List box. As a user selects from the list the coresponding text box needs to change to red. There are a lot of text boxes and I do not want to have an individual code for every selection made. I have used the code following however the final line keeps giving me an error...Any idea why this does not work.


Dim Fld As String

For Each Changed_Sel In [Forms]![frmMain_Form]![Changed_List].ItemsSelected

Fld = [Forms]![frmMain_Form]![Changed_List].ItemData(Changed_Sel)

DoCmd.GoToControl Fld 'Seems fine to here..the text box is highlighted.

DoCmd.SetProperty Fld, acPropertyForeColor, 112 'This line fails to find Fld???

Next Changed_Sel.

Any help would be greatly appreciated.

Curry
 
i would name your boxes something like:

txt1
txt2
txt3
etc...

then you can loop through them using an integer variable and the cstr() function. also, you can then use code like this:
Code:
forms("formname").controls("txt" & cstr(integer variable)).forecolor = 112
 
Thankyou...

I used your code like this to replace my last line...

[Forms]![frmMain_Form].Controls(Fld).ForeColor = 112

And it did exactly as I wanted...

Thanks
Curry
 
Try:

DoCmd.SetProperty Fld, acPropertyForeColor, RGB(255,0,0)
 

Users who are viewing this thread

Back
Top Bottom