Conditional formatting enable/disable toggle (1 Viewer)

swingline

Member
Local time
Tomorrow, 01:57
Joined
Feb 18, 2020
Messages
51
I have a report that is bing used as a quiz it has 4 conditional formatting rules that highlight a correct answers. I am looking for a way to disable to rules with a button so the quiz can be printed out without the answers highlighted. Thanks.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 15:57
Joined
Oct 29, 2018
Messages
21,358
Hi. Have you considered just copying the report and remove the CF?
 

swingline

Member
Local time
Tomorrow, 01:57
Joined
Feb 18, 2020
Messages
51
Hi. Have you considered just copying the report and remove the CF?
Yes, but the query Im using to select the questions from question database is random so. New copy with out formatting would produce a new random quiz.
 

swingline

Member
Local time
Tomorrow, 01:57
Joined
Feb 18, 2020
Messages
51
What I ended up doing was just to make a button called "Delete Answers" and add

Private SUB Command15_Click()
Answer1.FormatConditions.Delete
Answer2.FormatConditions.Delete
Answer3.FormatConditions.Delete
Answer4.FormatConditions.Delete
End Sub

This is good enough for the time being, I didnt know you could do conditional formating with vba. I'll workout how to toggle on and off later.
 

isladogs

MVP / VIP
Local time
Today, 22:57
Joined
Jan 14, 2017
Messages
18,186
I have several lengthy reports with some very complex colour formatting of data from crosstab queries.
For example:

Exam6StudentResidualGrid.gif


The complexity of the CF means the report can be very slow to load and can take well over a minute on older PCs
So, when selecting the report, a message box pops up giving users the option of printing a version without CF ... which loads instantly.

There is no need to have two separate reports for this. Use the message box to set the value of a boolean global variable blnCF (or use a tempvar) and use that as an OpenArgs argument when opening your report.

DoCmd.OpenReport "YourReportName",acViewPreview, , , , , , blnCF

Then in your report, check the value of blnCF and run the conditional formatting if its true
 

Attachments

  • Exam6KS4StudentGradeGrid.gif
    Exam6KS4StudentGradeGrid.gif
    62.9 KB · Views: 78

theDBguy

I’m here to help
Staff member
Local time
Today, 15:57
Joined
Oct 29, 2018
Messages
21,358
What I ended up doing was just to make a button called "Delete Answers" and add

Private SUB Command15_Click()
Answer1.FormatConditions.Delete
Answer2.FormatConditions.Delete
Answer3.FormatConditions.Delete
Answer4.FormatConditions.Delete
End Sub

This is good enough for the time being, I didnt know you could do conditional formating with vba. I'll workout how to toggle on and off later.
Hi. Glad to hear you got it sorted out for the moment. Good luck with your project.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 22:57
Joined
Feb 19, 2013
Messages
16,553
another option is to include the rule in your conditional formatting.

expressionis...[useCF] and [rightanswer]

and have an unbound checkbox control on your form for useCF
 

swingline

Member
Local time
Tomorrow, 01:57
Joined
Feb 18, 2020
Messages
51
Well, I have worked my way back to this problem and I am looking to add two buttons to my reports "Answers on" and "Answers off."

I currently have four text fields that have conditional formatting applied using the access conditional format tool.

"Expression is [Correct1]=True" then it fills the box green. I repeat this four times for each answer box. Then I have a button to remove the answers for printing that uses.

Code:
Private Sub Command26_Click()
Answer1.FormatConditions.Delete
Answer2.FormatConditions.Delete
Answer3.FormatConditions.Delete
Answer4.FormatConditions.Delete
End Sub

It works fine for most instructors, but there are a few that forget to print the answer key. So I would like to convert the conditional format tool results to VBA and stick it in a button called "Answers on"
 

Users who are viewing this thread

Top Bottom