472,378 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,378 software developers and data experts.

Using vba code to change the color of a form button in Access 2010

I have a form with a button to filter records and another to show all records. When the records are filtered I want the color of the button to change so that the user can immediately see that the records are filtered.

I changed the color on the form, noted the new color on the property sheet of the button. It is no longer a number, but text reflecting the "theme" that I am using. I tried using that text as follows:

Expand|Select|Wrap|Line Numbers
  1. cmdShowAll.Backcolor = "Accent 2, Lighter 40%"
No luck. There used to be numbers for the colors. Do I need to convert those theme colors back to numbers for the code? If so, how do I find them?
Nov 19 '11 #1
5 8873
446 Expert 256MB
Hi Sally
There may be something new in 2010 but the old way was to set the Background Style to Transparent and then draw a coloured rectangle behind it.

You should be able to change the colour of the rectangle via VBA but I have not gotten to grips with 'Styles' yet in the 2010 and I don't know if it gets over-written.

Best of luck!
Nov 19 '11 #2
Thanks for the tip. While I was working on that, I looked at the VBA property sheet for the control and it actually had the color number codes. So, I used that to set the properties with the appropriate number codes and it worked great. Thanks for taking the time to help me out!
Nov 19 '11 #3
32,511 Expert Mod 16PB
In truth the solution S7 was suggesting can be used, but it is only really necessary when being clever with conditional formatting. There is no reason in your situation to introduce separate elements into the mix when it can all be done with the existing control.
Nov 20 '11 #4
446 Expert 256MB
Sally, you are correct, BackgroundColor for a button now works as expected.

Access 2003 had a background colour attribute but it didn't work, hence the trick if you really did want to change the colour, (and why I thought you had a problem in the first place).

I checked before posting and found that it still does not work in Access 2010, but I was using an 'mdb' type database. Since your post I've checked and agree that it now works as expected with a 'accdb' type database.

Thanks for pointing this out!
Nov 21 '11 #5
32,511 Expert Mod 16PB
My mistake. I was also referring to Access 2003 but overlooked the fact (as S7 so clearly points out) that buttons do not have the facility to set a background colour. My mistake.

S7 has now clarified the situation fully though. Trust him. He knows what he's talking about (which I didn't this time :-().
Nov 21 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Dick | last post by:
I have a shared project that contains icons and bitmaps that are used throughout my suite of applications. I have to set Form.Icon, PictureBox.Image, etc. using code because the form designer...
by: matrekz42 | last post by:
Good morning folks, I have a progress bar in a form, and I would like to run the code for the progress bar through a Macro, so after each query finishes running, the bar will change. Is this...
by: skadu3 | last post by:
hello.. please tell me how to change color of button on mouse move in asp????
by: jaad | last post by:
Hello, I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta. When I...
by: sierra7 | last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control. I have a form which has been...
by: Alan Yim | last post by:
Hi folks, My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question...
by: araman | last post by:
Hello, I have a form and subform . The Main form contains four boxes to enter criteria for the query that fills the subform. Outside of the navigation form it works great. when i add it to the...
by: Lysander | last post by:
I'm sure many of you use backend and frontend databases. The backend holds all the tables, the frontend holds all the code. If you are developing for a multi-user system, you may have the same...
by: Music Man | last post by:
Greetings All: I built a database in Microsoft SQL Server 2000 and used Microsoft Access 2010 as the front end. The database is used to keep track of "issues" that rise out of my employment. ...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...
by: F22F35 | last post by:
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.