Full Version: VBA code in form problem
UtterAccess Forums > Microsoft® Access > Access Forms
ChrisSymonds
Hi,
need to update various controls based on specific criteria so I'm trying to create a generic string to use
Dim strLocation
strLocation = Me.cboV4SLocation.Column(3)
Debug.Print strLocation
The Debug.Print gives me the desired result (e.g. txtElCajon1 or txtPoway1, etc.) based on the location I select in the combobox. But when I use the string thusly I get an error message.
Forms!frmCounty.strLocation.BackColor = 255
If I replace strLocation with the actual name (e.g. txtElCajon1, txtPoway1) the backcolor works
How can I fix??
TIA
Chris
doctor9
Chris,
If I'm reading this correctly, strLocation is a variable that holds the various names of controls on your form. In that case, I think you need to refer to the control like this:
Forms!frmCounty.Controls(strLocation).BackColor = 255
Hope this helps,
Dennis
ChrisSymonds
Worked great. Thanks so much, syntax drives me crazy
hris
doctor9
Glad to help!
Dennis
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.