?
Solved

Global change to all form controls in MS Access

Posted on 2011-05-06
7
Medium Priority
?
716 Views
Last Modified: 2012-05-11
I have devised a way of having a parameterised method of changing the Form Detail and Header background colours for all forms in my database. I store these values in a table and these can be changed by the user, and these values are referred to by VBA each time a form is opened.

Is there a way of changing the background, font, border etc of each control in a form, without having to individually go to each control's properties? For example, is there a global method for each form, or a way of looping through each control as the form is opened?
0
Comment
Question by:rick_danger
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 35705944
to loop to all controls in the form

dim ctl as control
for each ctl in me.controls
    select case ctl.controltype
           case actextbox
     with ctl
          .backcolor=vbred
          .fontsize=9
     end with

    end select
next
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35706731
<Is there a way of changing the background, font, border etc of each control in a form, without having to individually go to each control's properties?>
Not that I know of

<For example, is there a global method for each form, or a way of looping through each control as the form is opened? >
?
Didn't you just say that you didn't want to loop the controls?

If your question is how to change the properties of *existing* controls on a form, ...then capricorn1 has posed the the most direct way that this can be done.

However, if your question is how to set up a form so that all contols have a certain default Properties set *before* they are inserted into the form, then do this:

Open a *new* form in design view
(Make sure that on the Ribbon, the Design tab is selected)
Press the F4 function key, to open the property box
Now, (with the property box still open) click on the TextBox control
You will immediately notice that the property box now says: "Default TextBox"
You can now set all the default properties you want.
*Close the property box*
Whatever properties you set, will now apply to any textbox inserted into *This* form.
(obviously, this can be done for any other control types as well)

JeffCoachman

0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 35706912
And to take Jeff's description of setting defaults for controls on a form.

I've created a template form (frm_Template) which has all of those settings for all of the controls the way that I want them (font type, size, colors, ...).  I start every new application with a copy of this form in my application and rather than using the form wizard to create my forms, I open that template, and save that form with a new name, then move out.

This ensures consistency throughout all of my forms.  That form also contains a textbox, and a combo box which have conditional formatting setup so that when the control has the focus, it has a certain back ground color.  When I start adding bound controls to my forms, I just copy these controls, which gives me that functionality for all of those types of controls.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 35706983

if you want, you can change the default settings of the Access .accdb with your own settings.
the settings will be used everytime you create a new .accdb

see this link on how to do it

http://accessjunkie.com/faq_50.aspx
0
 
LVL 49

Expert Comment

by:Dale Fye
ID: 35707079
Thanks Capricorn1, had not seen that previously.  I had been using a database template that I created for this purpose, but now I can just rename it and put it in the correct folder.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35707207
Plenty of great advice here!

;-)

Jeff
0
 

Author Closing Comment

by:rick_danger
ID: 35707401
Thanks
All the advice given was much appreciated, but your answer was absolutely the most relevant to the question asked.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question