X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Conditional Formatting - Access Macro, Access 2016    
post Aug 30 2017, 04:51 AM

Posts: 6
Joined: 4-February 17


I am trying to change my form heather based on a checkbox in Split Form.

For example: Check box "Approved" is ticked and my heather turns green. If it is not selected it turns yellow.

Unfortunately, when I am switching between the rolls in the form the heather is not changing frown.gif

This is the macro:

Private Sub Check318_Click()

If Me.Check318.Value = True Then
Me.Label319.BackColor = RGB(0, 255, 0)

Me.FormHeader.BackColor = RGB(50, 200, 50)


Me.Label319.BackColor = RGB(255, 255, 255)
Me.FormHeader.BackColor = RGB(255, 200, 100)
End If

End Sub
Go to the top of the page
post Aug 30 2017, 08:21 AM

Posts: 18,324
Joined: 29-March 05
From: Wisconsin


I'm going to repeat back to you what I think you're saying, to make sure we understand one another.

You want a checkbox to make the background of the entire form change to green when the record is "approved" and make the entire form yellow when the record is NOT approved.

If this is the case, you should put your posted code in the After Update event of the checkbox, not the Click event. Before you do that, you should name your checkbox something more meaningful, like "cbApproved" so it's more clear what it does. You'll see why in a moment. In fact, any time you're manipulating a control with code or referencing its value, you should really name the control. This will make your code easier to read a year later, when you're trying to determine what the code does. So, maybe consider renaming the label "Label319" as well. smile.gif

The next bit about "switching between the rolls in the form" sounds like you're navigating among the existing records. If that's the case, you just need to call the checkbox's After Update event from the form's Current event along these lines:

Call dbApproved_AfterUpdate

This will run the code that colors the form both after the checkbox value is updated, and after the user moves to a new record.

Finally, if this form is a Single form, the code should work just fine. But if the form is a Continuous form, the code will not work, as VBA like this will affect ALL of the visible records, not just the current one. If this is the case, you will need to skip using VBA, and actually use the built-in Conditional Formatting instead.

Hope this helps,

Go to the top of the page
post Sep 7 2017, 11:11 AM

Posts: 6
Joined: 4-February 17

Thank you very much for your help smile.gif
Go to the top of the page

Custom Search

RSSSearch   Top   Lo-Fi    11th December 2018 - 07:48 PM