UtterAccess.com
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    
 
   
bgpeny06
post Aug 30 2017, 04:51 AM
Post#1



Posts: 6
Joined: 4-February 17



Hello,

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)

Else

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
 
doctor9
post Aug 30 2017, 08:21 AM
Post#2


UtterAccess Editor
Posts: 17,589
Joined: 29-March 05
From: Wisconsin


bgpeny06,

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:

CODE
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,

Dennis

--------------------
(;,;) Li'l Cthulu says: Please talk about what you're trying to do, as well as how you're doing it.
Changing your real table name to "Table1" and your real form name to "Form1" in your posts makes it more difficult to understand what's going on, not easier.
Guidelines for Posting Questions
Go to the top of the page
 
bgpeny06
post Sep 7 2017, 11:11 AM
Post#3



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    19th September 2017 - 05:33 PM