Let me reword the question - I have a checkbox ([Active]) in a form and I would like if the box was checked that the color of the form itself changes, how do I do that?
Need to make a checkbox in a form change the form
Collapse
X
-
-
whatsyourtheory ,
It depends on what you want the form to do. To begin with, I would add some code to the OnCurrent Event of the form (assuming you have a check box called chkActive, which has the control source for the field "ISActive" on your Table):
The rest is up to you to figure out how you want to highlight this.Code:If Me.chkActive Then 'Add code to do things to identify an active record Else 'Add code to do things to identify an inactive record End If -
What I ended up doing was changing the conditional formatting on the title text so that when [Active]= False the background of the title text would be red. I also did this in some other forms, turning the email field inactive when [Active]= False. Since I don't understand the code at all, I pretty much mess around until something works - I wouldn't even begin to know where to put the code.Comment
-
Try this :- Go to the design view of your form.
- Make sure the Properties are shown on the screen.
- Select the section whose colour you're interested in changing. I'll assume that it's the Detail section.
- Note the existing value of [Back Color] from the properties. We'll refer to it in future as {A}.
- Change the colour of this section to the alternate colour you wish to use when your CheckBox is set to True.
- Note the new value of [Back Color] from the properties. We'll refer to this in future as {B}.
- Update the [Tag] property to the following - remembering to replace {A} and {B} with the values you noted earlier :
{A}|{B} - Click on (to select) your CheckBox control.
- Find the Event property After Update and double-click the text. This will set the value to the text "[Event Procedure]".
- At the right of this property you should now see a button with an ellipsis (...). Click on that.
- Having been taken to where you can enter your code paste the following in (Making sure not to duplicate what's already there) :
Code:Private Sub Active_AfterUpdate() With Me.Detail .BackColor = CLng(Split(.Tag, "|")(IIf(Me.Active, 1, 0))) End With End Sub
If you follow these instructions carefully you should have exactly what you need as well as a clue as to how to get to where you can enter code for a form ;-)
PS. I updated the post after I realised the name of the CheckBox had been included in a previous version of the question.Last edited by NeoPa; Jun 28 '14, 02:59 PM.Comment
Comment