Changing back color of txtboxes and cbo

J

John Fennell

Can anyone tell me what the code would be to change the color of text boxes
and combo boxes on Main and subforms on the Main form open event. Also I
would like to use colors other than the vb colors for example
-2147483643 = white instead of vbWhite
 
W

Wayne Morgan

To change the back color of a control you would use syntax similar to

Me.ctlMyControl.BackColor = vbWhite

The vbWhite could be replaced with a number as you mention. To get the
number, I've found it easiest to open the form in design mode, open the
Properties sheet for the control, and click the ... button on BackColor.
This will let you select the color you want and place the number in the
Properties sheet. Just copy and paste this number into your code instead of
the vbWhite.

To refer to the control on a subform from the main form you would use syntax
similar to

Me.ctlNameOfSubformControl.Form.ctlNameOfControl.BackColor

The subform isn't actually on the main form, it is in a subform control on
the main form. Frequently, the name of this control and the name of the
subform itself are the same, but they don't have to be.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top