Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

changing backcolor based on value of dropdown

Status
Not open for further replies.

at51178

Technical User
Mar 25, 2002
587
US
Hey guys


I have a form with a dropdown box that has 78 work station ids for the department. I also have created 78 boxes.
I have named the each of the 78 boxes based on the choices in the dropdown.

So if I have a computer with the ID AT123456 then I created a box named AT123456.

What i am looking to do is if somepne chose AT123456 from the dropdown list then the back color of the box name AT123456 will turn black.


Since I didn't want to write code for each option. I decided to use the below code but for some reason it doesn't work can someone help me.
After update

Dim ID as string
Id = cbo_ID.value

ID.backcolor = black

What I am looking to do is to tell access to read the value of the dropdown and use the dropdown value as the name of the appropriate box to change the back color to black.So that when I choose the option AT123456 from the dropdown the the box named AT123456 will be changed to black.

I hope this makes sense

let me know if you need further explanation.

 
Try this:

Dim ctrl as Control
For Each ctrl in Form.Controls
Select Case ctrl.ControlType
Case acRetangle:
if ctrl.Name = me.cbo_id then
ctrl.backcolor = 0
else
end if
Case Else
Next ctrl



"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
yes that is what i am looking to do but when I try to run the script I get an error that says

next without for

 
I Figured out why I was getting that message

I had to add a
end slect
after
case else

but when I run the code nothing is happening
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top