Loading
Ozgrid Excel Help & Best Practices Forums

Excel Training / Excel Dashboards Reports



Results 1 to 5 of 5

Thread: VBA Multipage Control Displays wrong page

  1. #1
    Join Date
    28th May 2012
    Posts
    3

    VBA Multipage Control Displays wrong page

    Hello,

    I have a multipage control on a userform where when data is changed on the form, the user must save the changes or cancel the changes prior to switching to the other page on the multipage control. I have the following code:

    VB:
    Private Sub MultiPage1_Change() 
        If mDataChanged And MultiPage1.Value = 1 Then 
             ' If data has changed and user is attempting to switch to print page without saving updates
            MsgBox "             Your current changes have not been saved." & vbCrLf & _ 
            "Please Save or Cancel your changes before selecting the print page" 
            MultiPage1.Value = 0 ' Remain on current page, do not switch
        End If 
    End Sub 
    
    
    The strange thing is that when the user has not saved/cancelled changes and attempts to change pages, the appropritate message shows up, the correct tab is selected at the top of the form, but the page displayed is the page the user attempted to switch to. Is there another way to show the correct page in order to be certain the correct page is displayed, not just the tab at the top of the control?

    Any suggestions?
    Thanks,
    Dave

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    23rd April 2007
    Posts
    3,886

    Re: VBA Multipage Control Displays wrong page

    The code as written works for me (assuming that mDataChanged is a boolean value that acts appropriatly).
    Have you tried adding
    VB:
    Me.Repaint 
    
    
    at the end.

    If that doesn't work, what is mDataChanged?

    Alternatly, you could change things so that rather than set mDataChanged to True/False, you could set MultiPage1.Pages(1).Enabled to False/True.

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    2nd May 2008
    Location
    Ubique
    Posts
    2,468

    Re: VBA Multipage Control Displays wrong page

    I've seen that behaviour a lot with multipages. Best solution I can suggest is to not allow the user to use the tabs to change pages. Hide the tabs and replace them with your own buttons that only change page after validating the current data.
    Rory
    Theory is when you know something, but it doesnít work. Practice is when something works, but you donít know why. Programmers combine theory and practice: nothing works and they donít know why

  4. #4
    Join Date
    28th May 2012
    Posts
    3

    Re: VBA Multipage Control Displays wrong page

    Quote Originally Posted by mikerickson View Post
    The code as written works for me (assuming that mDataChanged is a boolean value that acts appropriatly).
    Have you tried adding
    VB:
    Me.Repaint 
    
    
    at the end.

    If that doesn't work, what is mDataChanged?

    Alternatly, you could change things so that rather than set mDataChanged to True/False, you could set MultiPage1.Pages(1).Enabled to False/True.

    I tried "me.repaint" this does not work. Thanks for the view and attempt to fix.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    28th May 2012
    Posts
    3

    Re: VBA Multipage Control Displays wrong page

    Quote Originally Posted by rory View Post
    I've seen that behaviour a lot with multipages. Best solution I can suggest is to not allow the user to use the tabs to change pages. Hide the tabs and replace them with your own buttons that only change page after validating the current data.
    This seems to be the way to go. Then the tab only changes when I command it to, not the page. For whatever reason, it only switched the tab heading when using the "Multipage1_Change" event to validate.

    Thanks for the tip.
    Dave

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Identify Active Page Of A MultiPage Control
    By xltrader100 in forum Excel General
    Replies: 6
    Last Post: January 5th, 2014, 11:02
  2. Control names on a copied page in multipage
    By Elysiume in forum Excel General
    Replies: 12
    Last Post: July 9th, 2011, 05:21
  3. Determine Active Control On Multipage Control
    By Brian.Crawford in forum Excel General
    Replies: 3
    Last Post: October 6th, 2007, 08:55
  4. Multipage - Page Control
    By Simon Perkins in forum Excel General
    Replies: 8
    Last Post: October 5th, 2005, 16:31
  5. Multipage control vs userform control
    By bigdguitars in forum Excel General
    Replies: 11
    Last Post: February 16th, 2005, 01:30

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
  •  
porno