473,401 Members | 2,139 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 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 9006
sierra7
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!
S7
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
NeoPa
32,556 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
sierra7
446 Expert 256MB
Hi
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!
S7
Nov 21 '11 #5
NeoPa
32,556 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

0
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...
3
matrekz42
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...
1
by: skadu3 | last post by:
hello.. please tell me how to change color of button on mouse move in asp????
5
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...
2
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...
1
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...
0
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...
0
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...
1
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. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.