Need to make a checkbox in a form change the form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • whatsyourtheory
    New Member
    • Jun 2014
    • 4

    Need to make a checkbox in a form change the form

    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?
    Last edited by NeoPa; Jun 28 '14, 02:56 PM. Reason: Thought I might have been confusing.{NeoPa} re-added some important information left out after the edit.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    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):

    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
    The rest is up to you to figure out how you want to highlight this.

    Comment

    • whatsyourtheory
      New Member
      • Jun 2014
      • 4

      #3
      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

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32662

        #4
        Try this :
        1. Go to the design view of your form.
        2. Make sure the Properties are shown on the screen.
        3. Select the section whose colour you're interested in changing. I'll assume that it's the Detail section.
        4. Note the existing value of [Back Color] from the properties. We'll refer to it in future as {A}.
        5. Change the colour of this section to the alternate colour you wish to use when your CheckBox is set to True.
        6. Note the new value of [Back Color] from the properties. We'll refer to this in future as {B}.
        7. Update the [Tag] property to the following - remembering to replace {A} and {B} with the values you noted earlier :
          {A}|{B}
        8. Click on (to select) your CheckBox control.
        9. Find the Event property After Update and double-click the text. This will set the value to the text "[Event Procedure]".
        10. At the right of this property you should now see a button with an ellipsis (...). Click on that.
        11. 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

        Working...