Results 1 to 3 of 3

Excel 2010 User_Form Activate Event Not Updating form Check boxes

Threaded View

  1. #1
    Registered User
    Join Date
    08-10-2011
    Location
    Orlando
    MS-Off Ver
    Excel 2010
    Posts
    1

    Unhappy Excel 2010 User_Form Activate Event Not Updating form Check boxes

    Hi all. I'm writing a performance appraisal tool in Excel, using mostly VBA. From the main sheet I call a user_form via a macro assignment.

    The user_form opens and displays 7 Check boxes. My intent is to go to a worksheet , read a value that will be set to either TRUE or FALSE, and assign it to a corresponding temporary variable.

    The next step is to use an IF statement to determine if the value is TRUE, and if so, set the corresponding check box to true (ckecked), or if FALSE, then set the Corresponding check box value to false.

    The code is shown below. The message boxes added were for troubleshooting. What's interesting is that the First time I run the form, all check boxes are shown as unchecked (value = false). Once I check a box and save, then hide it, the next time I unhide (activate) it, the chack boxes behave as I expect them to from that point on. If I exit the workbook and re-enter, then my initial problem is back.

    MsgBox ("SMART Value 1 = " & Sheets("SMART").Cells(1, 7).Value) Evaluates to "True" on first run.

    MsgBox ("TempGoal1Vis =" & Me.TempGoal1Vis) Evaluates to "True" om first run.

    Then my next message is: MsgBox ("Hit if-for False " & Me.CheckBox1.Value) which is False.

    I'm fairly good at VB, but am finding the excel VBA a bit constraining and the more advanced features of VBA not so well documented.

    Any suggestions on how to attack this are GREATLY appreciated. Thank you!


     Public TempGoal1Vis As String
     Public TempGoal2Vis As String
     Public TempGoal3Vis As String
     Public TempGoal4Vis As String
     Public TempGoal5Vis As String
     Public TempGoal6Vis As String
     Public TempGoal7Vis As String
    
      Sub Userform_Activate()
    
        Me.TempGoal1Vis = Sheets("SMART").Cells(1, 7).Value
        Me.TempGoal2Vis = Sheets("SMART").Cells(2, 7).Value
        Me.TempGoal3Vis = Sheets("SMART").Cells(3, 7).Value
        Me.TempGoal4Vis = Sheets("SMART").Cells(4, 7).Value
        Me.TempGoal5Vis = Sheets("SMART").Cells(5, 7).Value
        Me.TempGoal6Vis = Sheets("SMART").Cells(6, 7).Value
        Me.TempGoal7Vis = Sheets("SMART").Cells(7, 7).Value
        
    MsgBox ("SMART Value 1 = " & Sheets("SMART").Cells(1, 7).Value)
    MsgBox ("TempGoal1Vis =" & Me.TempGoal1Vis)
    
        If Me.TempGoal1Vis = "TRUE" Then
           MsgBox ("Hit if-for True " & Me.CheckBox1.Value)
           Me.CheckBox1.Value = True
        Else
           MsgBox ("Hit if-for False " & Me.CheckBox1.Value)
           Me.CheckBox1.Value = False
        End If
    '   -----------------------------------------------
        If TempGoal2Vis = "TRUE" Then
           Me.CheckBox2.Value = True
        Else
           Me.CheckBox2.Value = False
        End If
    '   -----------------------------------------------
        If TempGoal3Vis = "TRUE" Then
           Me.CheckBox3.Value = True
        Else
           Me.CheckBox3.Value = False
        End If
    '   -----------------------------------------------
        If TempGoal14Vis = "TRUE" Then
           Me.CheckBox4.Value = True
        Else
           Me.CheckBox4.Value = False
        End If
    '   -----------------------------------------------
        If TempGoal5Vis = "TRUE" Then
           Me.CheckBox5.Value = True
        Else
           Me.CheckBox5.Value = False
        End If
    '   -----------------------------------------------
        If TempGoal6Vis = "TRUE" Then
           Me.CheckBox6.Value = True
        Else
           Me.CheckBox6.Value = False
        End If
    '   -----------------------------------------------
        If TempGoal17Vis = "TRUE" Then
           Me.CheckBox7.Value = True
        Else
           Me.CheckBox7.Value = False
        End If
    '   -----------------------------------------------
    
    End Sub
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1