Can someone please guide me an easy way of having more than three conditional formatting conditions?
Conditional Formatting ?
Collapse
X
-
Tags: None
-
Originally posted by tulikapuriCan someone please guide me an easy way of having more than three conditional formatting conditions?
Code:Private Sub Form_Current() Select Case Me![txtPostalCode] Case 98105 Me![txtPostalCode].ForeColor = QBColor(2) Me![txtPostalCode].FontBold = True Me![txtPostalCode].FontUnderline = False Case 98122 Me![txtPostalCode].ForeColor = vbBlue Me![txtPostalCode].FontBold = False Me![txtPostalCode].FontUnderline = True Case 98401 Me![txtPostalCode].ForeColor = QBColor(4) Me![txtPostalCode].FontBold = True Me![txtPostalCode].FontUnderline = False Case 98033 Me![txtPostalCode].ForeColor = QBColor(3) Me![txtPostalCode].FontBold = True Me![txtPostalCode].FontUnderline = False Case Else Me![txtPostalCode].ForeColor = 0 Me![txtPostalCode].FontBold = False Me![txtPostalCode].FontUnderline = False End Select End Sub
-
Originally posted by ADeziiI'm afraid that you will have to take the code route for that. Here is a simple example based on a Postal Code Field (txtPostalCode) on a Form:
Code:Private Sub Form_Current() Select Case Me![txtPostalCode] Case 98105 Me![txtPostalCode].ForeColor = QBColor(2) Me![txtPostalCode].FontBold = True Me![txtPostalCode].FontUnderline = False Case 98122 Me![txtPostalCode].ForeColor = vbBlue Me![txtPostalCode].FontBold = False Me![txtPostalCode].FontUnderline = True Case 98401 Me![txtPostalCode].ForeColor = QBColor(4) Me![txtPostalCode].FontBold = True Me![txtPostalCode].FontUnderline = False Case 98033 Me![txtPostalCode].ForeColor = QBColor(3) Me![txtPostalCode].FontBold = True Me![txtPostalCode].FontUnderline = False Case Else Me![txtPostalCode].ForeColor = 0 Me![txtPostalCode].FontBold = False Me![txtPostalCode].FontUnderline = False End Select End Sub
Comment
-
-
Originally posted by ADeziiThe code would be written in the Form's Current() Event as indicated so that it may reflect different States for each Record.Comment
-
Originally posted by tulikapuriI am trying to do the conditional formatting in a report where i have added some other sub reports aswell, so how do i write the code for tht now?
Code:Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer) Select Case Me![Title] Case "Sir" Me![Title].FontWeight = Bold Me![Title].FontSize = 12 Me![Title].FontUnderline = False Me![Title].BorderStyle = 1 Case "Mr." Me![Title].FontWeight = Bold Me![Title].FontSize = 10 Me![Title].FontUnderline = True Me![Title].BorderStyle = 0 Case "Dude" Me![Title].FontWeight = Normal Me![Title].FontSize = 12 Me![Title].FontUnderline = True Me![Title].BorderStyle = 0 Case Else Me![Title].FontWeight = Normal Me![Title].FontSize = 8 Me![Title].FontUnderline = False Me![Title].BorderStyle = 0 End Select
Comment
-
Can you please tell in more detail as to how can i get it done, actually i am new to access DB and dont know a lot of stuff.
I tried as desribed in your last post but i could not find the format () Event in report's detail section.
Thanks,Comment
-
Originally posted by tulikapuriCan you please tell in more detail as to how can i get it done, actually i am new to access DB and dont know a lot of stuff.
I tried as desribed in your last post but i could not find the format () Event in report's detail section.
Thanks,- Select your Report inh the Database Window
- Click on Design
- Double Click on the Detail Section (between Page Header and Page Footer)
- Click on Format
- Click on the Build (...) button
- Select Code builder
- Click on OK
- Copy and Paste the code in this Event (Format())
Comment
-
Thanks i got it right till here, but now since i have report with sub reports and each field had conditional formatting ,
First of all, can i look at the code for the three conditions i wrote , so that i get an e.g. of how to build the code.
Secondly, how do i do the conditional formatting for each and every single field?
For e.g. I have moisture values which should be green if its in the range 2.35 - 3.25 and then yellow if its less than 2.35 - 2.10 and yellow again if it is greater than 3.25-3.50. And red if it is less than 2.10 and greater than 3.5.Comment
-
Originally posted by tulikapuriThanks i got it right till here, but now since i have report with sub reports and each field had conditional formatting ,
First of all, can i look at the code for the three conditions i wrote , so that i get an e.g. of how to build the code.
Secondly, how do i do the conditional formatting for each and every single field?
For e.g. I have moisture values which should be green if its in the range 2.35 - 3.25 and then yellow if its less than 2.35 - 2.10 and yellow again if it is greater than 3.25-3.50. And red if it is less than 2.10 and greater than 3.5.
Code:Select Case Me![txtRange] Case Is > 3.5 Me![txtMoisture Values].ForeColor = vbRed Case 2.35 To 3.5 Me![txtMoisture Values].ForeColor = vbGreen Case 2.10 To 2.34 Me![txtMoisture Values].ForeColor = vbYellow Case Is < 2.1 Me![txtMoisture Values].ForeColor = vbRed Case Else Me![txtMoisture Values].ForeColor = vbBlack End Select
Comment
-
Originally posted by ADeziiHere is a Code Templqate:
Code:Select Case Me![txtRange] Case Is > 3.5 Me![txtMoisture Values].ForeColor = vbRed Case 2.35 To 3.5 Me![txtMoisture Values].ForeColor = vbGreen Case 2.10 To 2.34 Me![txtMoisture Values].ForeColor = vbYellow Case Is < 2.1 Me![txtMoisture Values].ForeColor = vbRed Case Else Me![txtMoisture Values].ForeColor = vbBlack End Select
Comment
-
Comment
-
Comment