+ Reply to Thread
Results 1 to 16 of 16

Issue with multipage form page changes

  1. #1
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Issue with multipage form page changes

    I suspect this may be a long post...apologies in advance.

    I have a multipage form with 12 tabs (index 0-11) designed for use by users to enter data for a model. That was fine, but then they asked for the ability to have it also edit previous entries, and I'm having a weird issue with one of the event handlers that I use to read in old data.

    The issue starts on this tab, which is index 3

    ROIpage.JPG

    If the YES radio button under Common Repairable is selected, the event handler takes them over to another tab

    CommonalityPage.JPG

    (which is index 9) to enter some additional data, and then come back. This works fine for new data entry, but the issue comes in when they're editing a previous entry. Here's how it should work...

    This is the event handler for whenever there is a page change:

    Please Login or Register  to view this content.
    The important block of code is

    Please Login or Register  to view this content.
    So if we're on page 3, and we're in the edit mode, the code should
    -- make tab index 9 visible
    -- switch to tab index 9
    -- make all the other tabs invisible

    But here's a screen shot from when I stepped through that code in the debugger

    ErrorROIPage.JPG

    You'll note that the tab title is "Commonality" which is the title of tab index 9, but the contents of the tab are still index 3.

    What's even more bizarre is that if I click the next button in the lower right, whose handler just says multipage1.value = multipage1.value + 1, then I'm suddenly taken to the correct tab 9. What's going on?
    Attached Images Attached Images

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Issue with multipage form page changes

    Hello jerH,

    It would be very difficult to troubleshoot your problem using what you have posted.

    If you can post the workbook, please do.

    Remember to change or redact any information that is sensitive in nature, i.e. private, personal or confidential before you post the workbook.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    Okay...the whole workbook is attached. I'm quite certain this isn't the only error in it though, as it's still a work in progress. I'm sure it's also a mess of spaghetti to more experienced developers.

    That said, to duplicate the issue, select "Edit existing alternative" from the main menu, then press the "Tactical Entries" button, select "test_it_all" from the list box and press the "Edit Selected Alternative" button. Using the "next" buttons move on to the page titled "ROI". The page change event handler should at this point take you to page titled "Commonality" to edit those entries...this is the problem I described in OP.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    Update:

    I tried forcing the issue by explicitly setting focus to one of the text boxes on the tab (index 9) that is not appearing. So the event handler now includes

    Please Login or Register  to view this content.
    where txtSytem is a textbox on page index 9. I get a runtime error that says
    Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus
    Don't know where to go at this point. I've explicitly made the tab visible, and I know a textbox can accept focus....

  5. #5
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Issue with multipage form page changes

    Have you tried adding a Userform1.Repaint line after juggling all the visible properties?

    Also instead of changing the Visiblity of each page, would setting MultiPage1.Style to fmTabStyleNone at design time work for your situation?
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    This is the first time I've worked with the multipage control, so I'm not familiar with fmTabStyleNone, I'll look into that.

    I've used this approach throughout the form...hiding tabs when they're not in use and making them visible when they are...and it works everywhere but here.

    I also tried your suggestion of calling .Repaint just before I try .SetFocus and I still get the same error.

  7. #7
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    I've now tried the following in an attempt to force the update

    Multipage1.pages(9).visible=true
    Multipage1.pages(9).enabled=true
    Multipage1.value=9
    txtSystem.setfocus

    And I still get the runtime error on the setfocus...

  8. #8
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Issue with multipage form page changes

    I notice that you are using EnableEvents. That does not effect userform events. To prevent cascading UF events, one declares a Boolean variable and uses that.


    Please Login or Register  to view this content.
    Note that all the events for all controls should have the If DisableMyEvents Then... line at their start.

  9. #9
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    EnableEvents is a public boolean...the page change event handler checks it first thing and if it's false then it bails.

  10. #10
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    Also, based on some things I'd read in other forum threads, I tried adding DoEvents in there prior to setting focus...no change.

  11. #11
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    And I've now tried part of the solution from this post by creating a public sub in a module to handle the change of the multipage1.value and that didn't work either. Haven't tried doing it with OnTime yet....this is getting ridiculous.

  12. #12
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Issue with multipage form page changes

    I haven't had time to really dig into your code, but if you set the .Style to no tabs, then you can ignore fiddling with Enabled or Visible settings of the pages.

    A page's Visible and Enabled property should both be True before setting the value of the MultiPage to that page.

    I'll dig into this more after work.

  13. #13
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    I appreciate your help. I'm gathering this has something to do with trying to change the multipage value inside the pagechange event handler. I take your point about changing the .style to no tabs and that may be what I have to do...but this is on the order of 3,000 lines long and was supposed to have been finished last week this is the only issue right now (as far as I know) standing between me and being done with this and moving on to something more fun. I'd hate to have to make significant changes to the design at this stage.

  14. #14
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Issue with multipage form page changes

    That's the thing, change the style to no tabs, take out the .Visible part that isn't working, and it will all work fine.
    Assuming that ALL your page changes are driven by buttons or other controls, i.e. that you anticipate the user never choosing between tabs, Changing the .Style to no tabs won't require any changes to the code that is working. That's the first thing I'm going to look for when I download your file.

    Edit: Well, I see that that assumption isn't correct.
    Last edited by mikerickson; 01-07-2016 at 09:43 PM.

  15. #15
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    I think I can make that work....just more rework than I was hoping to have to do

  16. #16
    Registered User
    Join Date
    12-17-2012
    Location
    Dayton, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    31

    Re: Issue with multipage form page changes

    It seems to be working now, but still some odd behavior.

    I changed the style to no tabs and got rid of all the fiddling with .visible. I still had to use the application.ontime approach to change the page within the pagechange event handler though. And, and this is the really weird part, I still can't setfocus to a text box on the page after switching to it. I get the same runtime error that says
    Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus
    But if I take out the setfocus line, everything works just fine. And since the textbox I was trying to setfocus to is the first one on the page, the cursor is sitting there anyway...

    Thanks for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. how to switch multipage page from multipage change event??
    By jed38 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-27-2015, 10:31 AM
  2. Replies: 4
    Last Post: 08-28-2014, 02:23 AM
  3. [SOLVED] ActiveControl - Return non-Multipage control when Form contains Multipage?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-04-2014, 08:37 PM
  4. [SOLVED] MultiPage Form / cell to show active page
    By ckk403 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2012, 04:02 PM
  5. Changing the Color of Page on a MultiPage Form
    By NaNaBoo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-31-2009, 04:21 AM
  6. [SOLVED] Multipage form: Referencing controls on one page
    By Post Tenebras Lux in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-11-2006, 02:45 PM
  7. Adding controls to each page in a multipage form
    By michael fuller in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-13-2006, 05:50 PM

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