473,396 Members | 2,090 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,396 software developers and data experts.

Conditional Formatting

418 256MB
I looked up the Help key to find out more about conditional formatting in Access. But all I could find is this
Expand|Select|Wrap|Line Numbers
  1. To apply conditional formatting to a control on a data access page, you need to write a VBA event procedure.
I am trying to show certain data in different color on a report depending on a Yes/No data type. The field name is SPAP. How do I do this?

Can someone please help? Thanks.
May 13 '09 #1
3 1362
Denburt
1,356 Expert 1GB
I don't remember where I got the colors from, some I use some I don't.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
  2. On Error Resume Next
  3. '10292543
  4. '10282543
  5. ' Light BlueGeen 14282543
  6. 'LightGreen 10282643
  7. 'Mauve 11634643
  8. 'Light Purple 15634643
  9. 'Light Blue 16634643
  10. '79102
  11. '16633633
  12. '10079102
  13. Const cRed As Long = 9671679
  14. Const cYellow As Long = 10092543
  15. Const cBlue As Long = 16634643
  16. Const cwhite As Long = 16777215
  17. Const cPurple As Long = 16751052
  18. Const cGrey As Long = 13487565
  19. Dim ctl As Control
  20. Dim sec As Section
  21.          Set sec = Me.Section("Detail")
  22. If Me!SPAP= True Then
  23.             sec.BackColor = cYellow
  24. Else
  25.           sec.BackColor = cwhite 
  26. End If
  27.  
  28. 'Use the following to alrternate colors
  29. '         If sec.BackColor = cwhite Then
  30. '            sec.BackColor = cGrey
  31. '         Else
  32. '            sec.BackColor = cwhite
  33. '         End If
  34.  
  35.  
May 13 '09 #2
NeoPa
32,556 Expert Mod 16PB
M,

There is no need to apply the conditional formatting programmatically. It can be done in the design of the form.

Open form in Design View. Select the control and then Format / Conditional Formatting....

From there it should be reasonably straightforward.
May 13 '09 #3
Denburt
1,356 Expert 1GB
LOL I do so much in code I forget about some of the more simple easier to use tools. Thanks NeoPa for helping to remind me that they do exist. Oh and M when he says
Format / Conditional Formatting....
he is referring to the format on the menu bar up top (FYI). I do think that for her report it may look better to color the whole row versus each control or a single control.
May 13 '09 #4

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

Similar topics

3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
4
by: Bradley | last post by:
I have an A2000 database in which I have a continuous form with a tick box. There is also a text box with a conditional format that is based on the expression , if it's true then change the...
8
by: Dimitri Furman | last post by:
Given: Access 2002/2003 A subform in datasheet or continuous view, placed on a tab page (this last may or may not matter) Conditional formatting applied to some controls on the subform - format...
2
by: Von Bailey | last post by:
I have a form where the conditional formatting is set on some fields to bold if certain conditions are met. However, when the conditions are met some of the data that is to bold is either not...
2
by: Sara | last post by:
The problem: Conditional formatting bold, red when field Value < date() sets the field background to white - always - whether condition is met or not. I want the field unfilled and just red/bold...
5
by: Andrew Chanter | last post by:
Does anyone know a way you can use conditional formatting to create a banded style view as is commonly seen on the internet. (In othe words the first record appears on a gray background, the 2nd...
1
by: GGerard | last post by:
Hello Is there a way to use a variable in the Conditional Formatting of a Textbox? Example : I want the background of a textbox in a continuous form to change color when the value of...
8
by: Typehigh | last post by:
I have many text fields with conditional formatting applied, specifically when the condition is "Field Has Focus". Without any events associated with the fields the conditional formatting works...
4
by: midlothian | last post by:
Hello, I have conditional formatting set up on a subform based on a calculated value in the underlying query. For instance, if Sales are >$1000, the query displays "Yes," otherwise it displays...
2
by: Filips Benoit | last post by:
Dear All, Access 2003 adp on SQL_server 2005 A continious form showing 1 month based on table 'CALENDAR_MONTH_GRID' and fill with a SP. Fields: Companyname, Day1, day2, etc. The value in the...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.