How to use VBA to Change Color of a Form

  • Thread starter Thread starter Brad
  • Start date Start date
B

Brad

I understand how to modify the color of a TextBox on a form using VBA code
such as
Forms!form2.text2.BackColor = vbGreen

Now I would like to change the color of the entire form.

How is this done?

Thanks
 
Brad said:
I understand how to modify the color of a TextBox on a form using VBA code
such as
Forms!form2.text2.BackColor = vbGreen

Now I would like to change the color of the entire form.

How is this done?


The form itself doesn't have a BackColor property, but each section of the
form does. So you can say, for example,

Forms!Form2.Detail.BackColor = vbGreen

If the form has a Form Header section and a Form Footer section, you have to
deal with them separately; e.g.,

' For a vibrant effect!
Forms!Form2.FormHeader.BackColor = vbRed
Forms!Form2.Detail.BackColor = vbGreen
Forms!Form2.FormFooter.BackColor = vbRed
 
I understand how to modify the color of a TextBox on a form using VBA code
such as
Forms!form2.text2.BackColor = vbGreen

Now I would like to change the color of the entire form.

How is this done?

Thanks

1) Change the back color of each section of the form.

If the code resides on the "Form2" form, you can use:

Me.Section(0).BackColor = vbGreen (the Form Detail section)
Me.Section(1).BackColor = vbGreen (the Form Header section)
Me.Section(2).BackColor = vbGreen (the Form Footer section)

2) Conversely, if you set the form's Picture property to a solid one
color Bitmap, that will over-ride all of the individual section
colors.
You will also need to set the PictureSizeMode to Stretch and the other
Picture properties as appropriate.
 
Fred,

Thanks for the assistance!

Brad


fredg said:
1) Change the back color of each section of the form.

If the code resides on the "Form2" form, you can use:

Me.Section(0).BackColor = vbGreen (the Form Detail section)
Me.Section(1).BackColor = vbGreen (the Form Header section)
Me.Section(2).BackColor = vbGreen (the Form Footer section)

2) Conversely, if you set the form's Picture property to a solid one
color Bitmap, that will over-ride all of the individual section
colors.
You will also need to set the PictureSizeMode to Stretch and the other
Picture properties as appropriate.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.
 
Back
Top