Conditional Formatting is not printing. (1 Viewer)

fireflyfranch

Registered User.
Local time
Yesterday, 23:06
Joined
May 4, 2017
Messages
10
I have a report that I have a text box set to change color based on a subreport through conditional formatting. It looks like that conditional formatting is working but only in the print preview. I does not show up in the report view or when I print. The text boxes in front are transparent and the box that changes color is set to solid. How do I get the color to print?
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 22:06
Joined
Feb 28, 2001
Messages
27,148
Depends on where the condition formatting is actually imposed.

If you do this in the OnFormat event code, you should be aware that this code does not run when printing. For that, you need the OnPrint event code. Don't ask me why, it has been too long since I looked into it, but it is true statement that when building a report, OnPrint and OnFormat are mutually exclusive and depend only on whether you are displaying or printing the report.
 

June7

AWF VIP
Local time
Yesterday, 19:06
Joined
Mar 9, 2014
Messages
5,466
Are you using the Conditional Formatting wizard for textboxes/comboboxes or are you controlling formatting with VBA?
 

June7

AWF VIP
Local time
Yesterday, 19:06
Joined
Mar 9, 2014
Messages
5,466
Because settings with the wizard should work in report view and print as well as preview. Format settings with VBA will not display in report view because the code has to be in Format event and that event does not trigger for report view. Also, AFAIK, VBA formatting cannot be conditional, all instances of control reflect the same setting. Unless the code is changing the Conditional Formatting properties https://msdn.microsoft.com/en-us/library/office/aa139965(v=office.10).aspx. However, the 3 condition limit no longer holds, now something like 50.

I cannot replicate the issue. If you want to provide db for analysis, attach to a post.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 04:06
Joined
Jan 14, 2017
Messages
18,209
Because settings with the wizard should work in report view and print as well as preview. Format settings with VBA will not display in report view because the code has to be in Format event and that event does not trigger for report view. Also, AFAIK, VBA formatting cannot be conditional, all instances of control reflect the same setting.

Sorry to disagree but VBA formatting certainly CAN be conditional.

In fact it allows you to do conditional formatting effects not possible with the wizard e.g. formatting the colour of a line
See this post I did earlier today
https://www.access-programmers.co.uk/forums/showpost.php?p=1532763&postcount=57

It also allows you to do complex formatting which may not be achievable with the wizard.
For example all the traffic light style conditional formatting on this crosstab query report is done using code:



The column widths are also adjusted using VBA depending on the number of columns used in the report to ensure everything fits in the page width

This following is part of the code - this is actually in the Report_Open event:

Code:
 ....
           With Me("Text" & intCount1).FormatConditions
            .Delete
            
            'Set traffic light for residuals
                Set Fcn = .Add(acFieldValue, acLessThanOrEqual, -12)
                    Fcn.ForeColor = vbWhite
                    Fcn.BackColor = vbRed
                '    'fc.FontBold = True
                    
                Set Fcn = .Add(acFieldValue, acBetween, -6, -11)
                    Fcn.ForeColor = vbBlack
                    Fcn.BackColor = 39423       'amber
                '    'fc.FontBold = True
                    
                Set Fcn = .Add(acFieldValue, acGreaterThanOrEqual, 6)
                    Fcn.ForeColor = vbWhite
                    Fcn.BackColor = vbGreen        '
                '    'fc.FontBold = True
                    
            End With
             ....
 

Attachments

  • ConditionalFormattingReportUsingVBA.jpg
    ConditionalFormattingReportUsingVBA.jpg
    39.8 KB · Views: 714

Users who are viewing this thread

Top Bottom