Solved

Conditional Formatting with More than 3 conditions

Posted on 2011-09-22
13
419 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
  • 3
  • 3
  • 3
  • +3
13 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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
 
LVL 119

Expert Comment

by:Rey Obrero
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 45

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now