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
Solved

Conditional Formatting with More than 3 conditions

Posted on 2011-09-22
13
423 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 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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 46

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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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 how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

856 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