How to use VBA to Change Color of a Form

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
0
Utf
12/2/2009 4:15:01 AM
access.modulesdaovba 1670 articles. 0 followers. Follow

4 Replies
3489 Views

Similar Articles

[PageSpeed] 37

"Brad" <Brad@discussions.microsoft.com> wrote in message 
news:3DA736F8-6ADD-455F-A3B3-2B0597C05152@microsoft.com...
>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


-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
12/2/2009 4:58:37 AM
On Tue, 1 Dec 2009 20:15:01 -0800, Brad wrote:

> 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
Please respond only to this newsgroup.
I do not reply to personal e-mail
0
fredg
12/2/2009 4:58:40 AM
Dick,

Thanks for the help, I appreciate it.
 
Brad


"Dirk Goldgar" wrote:

> "Brad" <Brad@discussions.microsoft.com> wrote in message 
> news:3DA736F8-6ADD-455F-A3B3-2B0597C05152@microsoft.com...
> >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
> 
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Utf
12/2/2009 3:29:01 PM
Fred,

Thanks for the assistance!

Brad


"fredg" wrote:

> On Tue, 1 Dec 2009 20:15:01 -0800, Brad wrote:
> 
> > 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
> Please respond only to this newsgroup.
> I do not reply to personal e-mail
> .
> 
0
Utf
12/2/2009 3:30:01 PM
Reply:

Similar Artilces:

send the same e-mail with one or two fields changed.......
I would like to send the same e-mail to many differnet people with one or two fields changed (for example the name of recipient and the date).How canthis be done?? I would also like to be able to save the e-mail and use it again and again. can anyone help cheers john If you have Word installed and it's the same version as Outlook (both 2003, for example), you can do a mail merge between the two. This would allow you to set up the text the way you want it to, and you can save the document for future use. Look at the following page for further information: http://www.slipstick.com/con...

Too Many IF Statements Nesting Error (Excel Formula Loop w/o VBA)
Hello Excel Problem Gurus, First of all, let me thank you in advance. I find it exemplary that you all can devote time to helping others who are having issues with their work. Hopefully one day I can be at a mentor level, and help others too. Hope you can help! I have an issue where I don't know how to write the formula that I need without going over on the nesting. The current formula that I have is as follows: =IF(OR(B7="",J7="",L7="",M7="",N7="",O7="",P7=""),"No Data",IF(V7="Yes",&qu...

why does sorting change a scatter plot graph?
Why does the way a spread sheet is sorted change the look of a scatter plot graph??? the graph is just a plot of two points, (X, Y) and these two points are definded by two collumns for a given row. The two collumns don't change, and the row all stays together, so why does it change where points are plotted out on the graph when you re-sort it? AndrewT420 - Usually, for an XY (Scatter) chart, with values of X in a column and corresponding values of Y in an adjacent column, for three or more points, Excel assumes (correctly) "Series in Columns." But, when you have only...

Can SUMPRODUCT be used for entire column?
This formula results in a numeric result: =SUMPRODUCT((A1:A20)*(B1:B20="b")) but this formula results in a #NUM! result: =SUMPRODUCT((A:A)*(B:B="b")) Which means I need to specify the length of the columns, which may grow over time. Any way to do this for the entire column, without having to specify the length of the column? XL07 removed the limitation on array formulas (which SUMPRODUCT is, even though it doesn't require CTRL-SHIFT-ENTER) and entire columns. For pre-XL07, one can use =SUMPRODUCT(A1:A65535, --(B1:B65536="b")) to get all but on...

Changing Prices in HQ.
Hi, I have this little issue. I want to change the put items on promotion using the price wizard using HQ. Unfortunately if I have stores who has differents prices for a same item the wizard do not make the proper change becuase it use the price already stored in the master table. Does anyone saw this issue before? Who was solved?. Thks in advance for your help. Rgds Rodrigo Hi there, The easiest way to look after this is to not change any data on the ITEM in HQ, but to simply do the worksheet for altering the sale price and then send it to the respective stores. Then in the works...

Content of emails is changing without any reason !
Hallo I changed operating system last week. From Win XP to Win 7. Used to work with Outlook Express at full satisfaction. I could transfer most of my emails automatically with export/import features of Microsoft software. But I suddenly discover 1 very big problem (bug ???) I am used to work with several maps, and hereby go to several levels deep. Such as : Saved mails Companyname Projectname Date of action Department Activity Name of patient Different emails So sometimes maps can go several levels deep. When I check ema...

Pass parameter from FORM to QUERY
I have an append query that I trying to call from a cmd btn...but it prompts me for the parameter(ie QuoteID)... How do I tye it into my call: Dim stQueName As String stQueName = "Quote Query" DoCmd.OpenQuery stQueName, acNormal, acEdit On Apr 13, 12:56 pm, jlt...@hotmail.com wrote: > I have an append query that I trying to call from a cmd btn...but it > prompts me for the parameter(ie QuoteID)... > How do I tye it into my call: > > Dim stQueName As String > stQueName = "Quote Query" > DoCmd.OpenQuery stQueName, acNormal, acEd...

Office 2007 forms
I am creating a form with office 2007, will those people who do not use office 2007 be able to fill in my form? should I save it in a particular format? thanks Provided you start from the normal template, don't use fonts that were introduced with Word 2007, and save the form in Word 97-2003 document format, anyone with Word 97 or later should be able to open it. Use only the legacy form fields, to which end http://gregmaxey.mvps.org/Classic%20Form%20Controls.htm will make things easier. -- <>>< ><<> ><<> <>>< ><<...

Saving toolbar changes
After spending a lot of time to customize a toolbar in Excel 2003, it disappears when opening up another file, or starting the app again. I repeatedly change it, save it as XLB, XLT, save multiple copies in every possible location...but the damn thing always defaults to its own toolbar settings. This makes toolbars almost useless. How can one insist that PPT use YOUR toolbar setting, rather than its own default Thanks. Hi Jeff, If I have a lot of tool bar changes to make, I close all the workbook that are not hidden then unhide my personal.xls from the Window menu. I don't know why...

Printing In Color
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) I am trying to print a document in word that is color but it is only coming out in black and white. How can I change the color settings on my printer? Word has no setting to print in color v. B/W -- that's a function of your printer & its driver software. The settings are available in the Print dialog in the Copies & Pages List, but exactly where the setting is located depends to a great extent on what printer you have. Some printers also have physical controls on the printer, itself, but that isn't common. ...

Can't create Organizational Forms Library in Exchange 2003 with SP
Hello, I cannot create an Organizational Form in EFORMS REGISTRY folder (from First Administrative Group->Folders->Public Folders->EFORMS REGISTRY in ESM). When I right-click the EFORMS REGISTRY folder and select New, there is no Organization Form. Instead, I only see Public Folder in the popup menu. Do you have any idea why Organizational Form menu does not show? My Exchange Server is Exchange 2003 with SP2. The login user is Administrator. Could you please help me? Thank you very much. Yang Is that account member of "Enterprise Admins" group? Yang Zhang wrote: &...

Change cannot be saved due to sharing violation
Hello I've this message while saving the excel file even if no change ha been done to the file. There is no share on this file (exclusive use) File resides on a network drive It's very disturbing Thanks for your help Vobiscu -- Vobiscu ----------------------------------------------------------------------- Vobiscum's Profile: http://www.msusenet.com/member.php?userid=245 View this thread: http://www.msusenet.com/t-187102186 http://support.microsoft.com/default.aspx?scid=kb;en-us;328170 Thanks for your answer, I will try tomorrow noo Vobiscu -- Vobiscu ----------------...

Using scanner in Word97
I want to scan a picture into word97 using my HP 4370 ScanJet. Could not find option of "From Scanner" under "Insert" --> "Picture". Apparently I must need some sort of Word97 Add-On. What and where is the add-on? Is it on the Office97 CD? Same applys to Excel97. Also, does microsoft sponsor a Word97 / Office97 discussion group? If so, would appreciate a link. "PSRumbagh" <PSRumbagh@discussions.microsoft.com> said this in news item news:39100DC1-A7EE-4679-881D-526BAA386620@microsoft.com... > I want to scan a picture ...

Changing query execution sequence
Hi all, I got a spreadsheet which would execute a bunch of queries. It's noted that the queries are executing in the sequence of when it was added to the spreadsheet. Does anyone out there know of a way to switch the order without deleting and recreating them? Thanks! Wing ...

Using Company Wide Mail Templates.
Hi, I do not know if i am at the right spot here, or if it is evne possible, but i got the following question. My boss would like me to make sure that every outgoing mail has the same looks. It starts by adding a signature that is the same for everyone, except with ofcourse personalized information. This was easily done by giving everyone a signature. The next question is however, to put the head of our website, also above our mail. This means that every user that sends a mail, the mail will have a nice header, underneath that header, the mail is typed, and then its ended with the si...

How to track ActiveControl.Name when switching records in form with multiple subforms
I need to have a global variable always contain the name of the current form field. This bit of code is attached to the GotFocus event of all fields and the Enter event of all subforms: gxCurrentField = Me.ActiveControl.Name However it doesn't work properly when changing records in a subform. My parent form contains two subforms in a many-to-many relationship. The above variable usually ends up containing the name of the first field in the second subform when switching records in the first subform. How to correctly code this? Or is there some native variable I'm not aware of? I...

Dynamic Range Selection Using VBA
What I'm trying to accomplish is to be able to run a procedure that selects a range based on a number provided in another cell. For example; if the number 10 is in cell A1, then cells A20:A30 would be selected when I run the macro. If the number 6 is provided, then cells A20:A26 would be selected. Not sure where to start, so any help is appreciated. this may do what you want range("A20").Resize(range("A1").Value+1).select -- Gary Keramidas Excel 2003 "TEK" <TEK@discussions.microsoft.com> wrote in message news:DA9FFF99-FC28-...

Using later version of microsoft access
Hi, I've got access 2000 on my computer. When I go to open a database someone sent me I get an error message : this database is in an unrecognized format. The database may have been created with a later version of microsoft access. Is there any way I can open and use this file (short of upgrading to later version of access)? If you do not have Access 2002 or 2003, ask the person to save it in Access 2000 format for you. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at m...

how create Quota filter in WIndows 2003 R2 using Script
Hi all I need create quota filter in Server 2003 R2 using vbscript. quota filter should be applied to directories and not by users. I searched information about it on google without success. thank's in advance Daniel Hi Daniel. First you need open your FSRM (File Server Resource Manager), then you create a quota template, you must specify if your quota is "software" (just monitoring, but never deny the user) or "hardaware" (deny users when they use 100% of the quota), you must specify if you want send e-mail to user when this user use...

Automatic changes in cells
Hi for some reason I now have to save my work for any formlas etc to change when I update a worsheet, how can I stop this as it is a pain and sometimes I need to do changes to see how they work before saving the work. Many thanks Click on Tools | Options | Calculation tab and set to Automatic calculation, as it is probably set to Manual. You can press F9 to force a recalculation under a manual setting. Make sure you save the file with the Automatic setting, to avoid it happening next time. Hope this helps. Pete On Feb 1, 11:42=A0am, Office 2004 Test Drive User <heepenm...@yahoo.co.u...

cursor missing from form textboxes
I believe that I know 98% of the little intricacies of Publisher, but I'm stumped on this one. I created a website with a contact page and none of the standard textboxes will show a cursor to indicate with field you are in (I've even made the site live to double check). If you tab between textboxes, the tabbing works, as does typing, there is just no visual cursor to indicate where you are. If you click on the first textbox and type, all is good you can tab to the next box and type, and it's fine. I'd like to have the visual cursor show and can't get it. I also have ...

Change the text of a shape rather than its master
Hi, I build custom masters by mixing two general shapes, say square and circle together, and have text on both the shapes. But after I drop an instance of the master into a page, I cannot modify the text of the instance. To do so, I need to modify the text on the master, which is non-sense for me. How to change the text of a shape without modifying its master? Thanks! How are you doing this? By code or by the UI? Are you grouping the shapes? If you drag two shapes to the stencil, it will group the shapes. So instead of a square and a circle you have three shapes. A Square, Circle and the...

cell colour change when set markers are reached
i need to get a cell to change colour when markers are reached eg a qualification lasts 12 months. what i want to do is have the cell change from yellow to orange to red as the expiry date gets closer. If column A contains expiry dates then select column A, Formats>Conditional Formatting>formula1: =DATEDIF(TODAY(),A1,"m")<1 red for 1 month Click Add button, formula2: =DATEDIF(TODAY(),A1,"m")<2 orange for 2 month Click Add button, formula3: =DATEDIF(TODAY(),A1,"m")<3 yellow for 3 month Adjust number of months as you like! Regards,...

Coloring a row
I have a spreadsheet and I want to have cells colored from column A to K if cell h is not blank. So if h3 has a date in it I want A3:K3 to be say light blue. This is for Office 2003. I can do it with conditional formating in 2007, but my work place doesn't have 2007. I did use column L and put an if statement to give a true or false in the cell depending on if the cell in col. h was empty or not. Any ideas how to get this to work? Hi John This sort of thing will work in 2003 conditional formating. In Cell A3 go to Format - conditional formattting. Formula is Paste...

Changing ip address of exchange server #2
Hi, I have a back-end server and a smtp server in DMZ. I want to change ip address of back-end server. are there any issues? all incoming and outgoing emails are going via smart host. Hi, No issues at all as long as you remember to change all the references to this server in your firewall, SMTP scanner etc. Leif "Jack Dorson" <JackDorson@discussions.microsoft.com> wrote in message news:FE5927A1-D20D-4C6B-991F-2E1EFD19434D@microsoft.com... > Hi, > > I have a back-end server and a smtp server in DMZ. > > I want to change ip address of back-end server. are ...