Results 1 to 8 of 8

Loop Statement : Use of string to refer userform object

Threaded View

  1. #1
    Forum Contributor
    Join Date
    02-09-2010
    Location
    Constanta
    MS-Off Ver
    Excel 2007
    Posts
    128

    Loop Statement : Use of string to refer userform object

    Greetings,

    In my userform I have several frames (Frames 2-6) that are enabled as per the optionbutton selection (enclosed in Frame1). By default the frames (2-6) are disabled. I tried to write a code where if the optionbutton selection changes any frames that have been previously enabled should be disabled before enabling the frame for the current optionbutton selection.

    I approached the problem by first identifying the name of the enabled frame using the below procedure.

    Private Sub NameEnabledFrame()
        CountFrames
        For i = 2 To iCountFra
            Set Fr = Me.Controls("Frame" & i)
                If Fr.Enabled = True Then
                    sFraName = Fr.Name
                End If
            'Disable all frames to clear memory
            Fr.Enabled = False
        Next
        MsgBox (sFraName)
    End Sub
    The correct frame name is returned irrespective of the order in which I click the optionbuttons. However when I add the line

    Me.Controls(sFraName).Enabled = True
    after the msgbox statement, the correct frame name is returned & hence the enabling takes place only if I click the optionbuttons in ascending order, ie, 1, 2, 5 etc. If I click optionbutton2 after clicking 5, the message box returns frame6 (corresponding to optionbutton5) with frame6 enabled. Frame3 (corresponding to optionbutton2) does not get enabled.

    Why is this happening? Please help.
    Asha


    N.B. Frame1 also has a combobox and textbox whose values will not change with a change in optionbutton selection.
    Last edited by asha3010; 07-10-2010 at 02:27 PM.

Thread Information

Users Browsing this Thread

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

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