Solved

Conditional Formatting with More than 3 conditions

Posted on 2011-09-22
13
426 Views
Last Modified: 2012-05-12
Hello Experts,

I have a subform (continuous), where I need to do a conditional formatting on a field based on the values on two other fields within the same row, but Access allows only 3 conditions + 1 Defaullt.

In my case, what i -need to do is:

If (Me.txtProd = "T1") And (Me.txStatus = "O") Then
    Bold = True
    BackColor = red
ElseIf (Me.txtProd = "T2") And (Me.txStatus = "O") Then
    Bold = True
    BackColor = pink
ElseIf N1, N2, C1, C2, E (5 more elseif's)
else
     bold = false
     backcolor = none
End If

Any help will be appreciated

Thank you
0
Comment
Question by:APD_Toronto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 3
  • +3
13 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36581764
see this link

Extending the Functionality of Conditional Formatting in Access
http://msdn.microsoft.com/en-us/library/aa139965%28office.10%29.aspx
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 36581804
There is no way past the limit of 3 concurrent formats (+default).

Unless you upgrade to A2010, where there are 50.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 36581817
Sorry cap but I don't think that will help.

As far as I know, all it does it give you the ability to change which 3 formats are currently being used; on a single form this can give the illusion of there being more than 3 but only 3 are available at any time.
0
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 36581838
not sure, but it might...
0
 
LVL 12

Expert Comment

by:ErezMor
ID: 36581923
From a2007 onward, you can use richtext fields (both in table columns and forms)
This requires some pre-planning , but with this feature you can have as many different visual effects on a continuous form as your pc display can handle
I actually implemented this in 2 of my projects, so ask for any specifics if you need
Again, you'll need to make some structural changes for it to work (for example, the row displayed is a mock up of actual data decorated by tags, and therefore isn't  edited directly but by a seperrate form
0
 

Author Comment

by:APD_Toronto
ID: 36581968
Erez,

how would i achieve my goal from my orig post with rich tex/

Does anyone know if i can run A2007 and A2010 RunTime on 1 machine? Or, if i se 2010 with the 50 conditions, will it work in 2007?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36582158
If it were me, I would just use a form in "single form" view.
Then you can use code (like what you posted) on the current event of the form to format the controls based on as many conditions as you need.


FWIW, the reason why CF is limited to 3 conditions is that beyond that you can lose track of what is what.
Then you end up having to create a color legend, ...then write code to update it, ...etc


Another option could be to create a Filter form to set/filter for each "Condition".
Then simply open the form and only show those records matching the condition.

A final option would be to use a report for this.
Then you could keep the "tabular/Continuous" look of the form, but still use code (this time on the Detail Format event) to create your more than 3 conditions.


JeffCoachman
0
 
LVL 48

Expert Comment

by:Martin Liss
ID: 36582934
Select Case True
    Case (Me.txtProd = "T1") And (Me.txStatus = "O")
        Bold = True
        BackColor = red
    Case (Me.txtProd = "T2") And (Me.txStatus = "O")
        Bold = True
        BackColor = pink
    Case "some condition"
        ' do something
    Case "some other condition" ' add as many other cases as you like
        ' do another thing
    Case Else
        Bold = False
        BackColor = none
End Select

Open in new window

0
 

Author Comment

by:APD_Toronto
ID: 36587942
If i do this, all rows change based on the last value changed


Private Sub setBGcolor()
    
    With Me.txtPickupTime
    
        If (Me.txtProdID = "T1") And (cboPickup.Value = "O") Then
        
            .BackColor = RGB(255, 0, 0)
            .FontBold = True
        
        ElseIf (Me.txtProdID = "T2") And (cboPickup.Value = "O") Then
        
            .BackColor = RGB(255, 51, 153)
            .FontBold = True
        
        Else
            
         '   .FontBold = False
            
        End If
        
        'MsgBox "COLOR"
        
        'me.cboPickup.Format = .Format
    End With
    
End Sub

Open in new window

0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36588420
So using a single form where this will work directly is not an option?

You seemed to have ignored my post...
0
 
LVL 77

Expert Comment

by:peter57r
ID: 36588537
You cannot achieve what you want through code.
Conditional formatting is the only relevant tool in a continuous form and you already know the limit for that.
0
 

Author Comment

by:APD_Toronto
ID: 36588557
boag - i thought i replied, guess not

i did not understand your post
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 36588594
OK, to avoid confusion, I'll let you continue with the previous Experts
0

Featured Post

Independent Software Vendors: 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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

717 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