BUG: MultiPage Controls on 2003

Sue brought this one to my attention. Changing the Value property of a MultiPage control in the Change event, causes the MultiPage to show incorrect information. To reproduce, follow these steps:

  1. Create a Userform
  2. Add a MultiPage control with 2 pages
  3. Add a TextBox to the first page of the MultiPage
  4. Add a CommandButton to the second page
  5. Put this code in the Change event

    Private Sub MultiPage1_Change()

        If Len(Me.TextBox1.Text) = 0 Then
            Me.MultiPage1.Value = 0
        End If
        
    End Sub

  6. Now run the form. This is what I get

    MPBug1

    Then switch pages without putting anything in the TextBox

    MPBug2

    It’s on Page1, but the contents of Page2 are showing. Strange. Here’s what I have for a workaround, but it’s not very pretty. In a standard module, put this

    Public Sub chMultiVal()
        UserForm1.MultiPage1.Value = 0
    End Sub

    and change the Change event to this

    Private Sub MultiPage1_Change()

        If Len(Me.TextBox1.Text) = 0 Then
            Application.OnTime Now + TimeSerial(0, 0, 0), “ChMultiVal”
        End If
        
    End Sub

14 Comments

  1. Andy Miller says:

    I’m not sure if this is a bug or not, but, in VBA, you can choose the Application.WorksheetFunctions.VLookup function. However, when trying to use it, it returns the Run-Time Error 4004 - Unable to get the VLookup property of the Worksheetfunction class.

  2. Andy Pope says:

    Assuming Sue is trying to prevent selection of Page 2 until the textbox on Page 1 contains some text you could try this alternative code.

    Private Sub MultiPage1_Click(ByVal Index As Long)
    If Len(Me.TextBox1.Text) = 0 Then
    Me.MultiPage1.Value = 0
    End If
    End Sub

  3. Sue says:

    Dick, this works great and I appreciate it so much…thanks for taking the time out…I am going to send this link to others that I know are having the same problem…Sue

  4. Juan Pablo G says:

    Andrew,

    I don’t think that’s a bug. But, if you use Application.Vlookup instead, it doesn’t create an error like that, it just returns the xlErrNa error.

  5. Juan Pablo G says:

    Sorry, I meant Andy, not Andrew…

  6. Andy Miller says:

    Speaking of bugs… I was just curious: since you’re an MVP, do you have the authority/status/ability to report bugs to Microsoft and have them actually pay attention?

  7. Dick says:

    Andy: We have a contact person (called a Lead) at Microsoft to whom we can report bugs. I don’t think we get any special treatment though. The only benefit that I’ve ever seen is that she reads the messages and frankly I wouldn’t know where else to submit them. I looked around microsoft.com for a bug submission page, but came up empty.

  8. Nitin says:

    I have been trying to solve this issue for the past week and this solution ROCKS. Thank you for posting the solution to this issue. Do you know the reason behind this issue or what causing it.

    Thank you

  9. Dick says:

    Nitin: I don’t know the cause. Even if MS let me see the code for Excel, I guarantee I wouldn’t understand it.

  10. Dave says:

    You’re a friggin’ genius! I’ve been pulling out what little hair I have left for two days over this one. BTW, this wasn’t a bug in Excel 2000, but cropped up in XP and 2003.

    Way to think outside the box!

    Thank you, thank you, thank you.

  11. Darren says:

    This bug still seesm to be around in Excel 2007. I’m so grateful to have found this page.

  12. Chris says:

    I have been struggling with this problem for over a week now.
    All of the code I wrote using Excel 2000 suddenly fell over when I “Up”graded to Excel 2003…
    I used Andy Pope’s suggestion of using the click event instead of the change event and its all working again.
    I can only guess that its an intentional fix in Excel 2003, preventing people from writing code which changes the multipage value, which is triggered by the multipage_change() event.
    I suppose its conceivable that the code could fall into the chain of:
    multipage_change() -> multipage.value = X -> multipage_change() -> multipage.value = X -> …

    And maybe theres something in Excel 2003 preventing this from happening.

    Anyway, my problem is fixed.

  13. Alan W says:

    Surfed in here today, and I appreciate the help very much. Great work around — thank you very much for a solution to my problem!! More proof that Microsoft does not always have all the answers!

    Thank you again,
    Alan

  14. Pete says:

    This tip is great and I can kind of re-work my user form to use this command and achievce what I need. Thankyou.

    However, ideally I would like to set the second page of my form only to be enabled when a certain check box on the first page is checked. Have tried a few things but no sucess. I’m very new to VBA so possibly I am making an ameteuristic mistake.

    Thanks in Advance for any help.

Posting code or formulas in your comment? Use <code> tags!

  • <code lang="vb">Block of code goes here</code>
  • <code lang="vb" inline="true">Inline code goes here</code>
  • <code>Formula goes here</code>

Leave a Reply