Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Event problems with Multipage (Excel 2000 sp3)

    I have a multipage form in an Excel workbook and I'm trying to use the _Enter, _Exit, and _BeforeUpdate event handlers for the textboxes I have on these pages. The problem is, the events seem to either fire multiple times, or not fire when expected.
    For instance, if the textbox is on one of the pages and I have a Finished button on the form itself, when the Finished button is clicked the form actually disappears before the _Exit procedure executes. The _BeforeUpdate seems to fire multiple times.
    Is this a known problem? I haven't been able to find any articles or other posts specifically about it. Does anybody know a workaround or a fix?
    Thanks in advance for any help at all!

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    Could you post a demo file or at least some code. Many times events are triggered multiple times since other code is doing something to trigger an event. Events may not be triggered if events have not been enabled (some code turns event handling off)

    Steve

  3. #3
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    I'll work up a demo but any form that works can easily be broken by moving the text boxes to a a multipage. The app I'm working in is way too big to post so I'll need to create a smaller one.
    Thanks for taking an interest.

  4. #4
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    Here's a brief demo. Each event has a msgbox so it's easy to see what's happening. I had expected the "any action" button to fire the events but it doesn't, even though the cursor no longer appears in the textbox (any idea why the cursor isn't there?). The exit event for the textbox doesn't fire when the Finished button is clicked until after the form unloads. By the way, the action I was trying to handle was editing the contents of the textbox and putting up an error message so the user could fix it. Since the button click doesn't fire the _Exit event, I switched to _BeforeUpdate.
    If you type in either textbox and hit the "any action" button the BeforeUpdate event fires but seems to cancel the rest of the action associated with button.
    I hope this shows what I mean.
    Thanks
    (I edited this post and replaced the demo. It now has two forms, one is a multipage, the other isn't. Both have identical code behind them. Clicking a button on the regular form DOES fire the exit event but for some reason it cancels the rest of the action of the button. I have to click again to make that code run.)

  5. #5
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    You mention 2 problems:
    1) "the events seem to either fire multiple times"
    Could you be more specific about this proble. I do not see the events firing too often or multiple times. The fire as I expect them to. COuld you give a series of pressese that show the "multiple times" in your sample?

    2) "the events seem to... not fire when expected"

    I think I "understand" (or at least have an explanation/workaround) to the Multipage form not triggering the exit event of the textbox. I don't completely understand the logic but "on some level" the multipage seems to be its own item (like a form within a form). When you are the multipage with TB1 pressed it is entered. When you leave the multipage and press either button, you do not exit the textbox, you exit the multipage:

    On the multipage, the textbox is still "entered", you have not exited it, so no exit code. It is also not shown as selected (since the multipage is not selected so why should it show what is selected on the multipage? - hence no TB seems selected). If you enter the multipage again, you will see that the TB is still selected/has the focus (on the multipage).

    After closing the form (proper) the multiplage closes and then you exit the TB.

    To be honest, I am not sure why it works this way [but who really understands the minds of the MS programmers?], I would have expected the same behaviour you anticipated (and did not see).

    The workaround is not to use the TB exit events but to use the multipage exit event and have the code triggered from this.

    I hope this helps...
    Steve

  6. #6
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    Thanks for your help Steve. As you suggested above, other code in my app must be affecting things. This demo that I posted is quite simple and does not have the other code which must be affecting my app. I can't get the demo to fire the events multiple times either. When I used the _BeforeUpdate event in my app, that fired many times.
    The problem with using the multipage exit event is that it doesn't tell me which textbox was active at the time (I solved that by setting a flag in the _Enter events) and it doesn't fire when switching from one textbox to another, as you saw. I could use a combination of exit events for the textboxes and the multipage but I'll need to keep track of what was active and which fired so I don't process a textbox twice.
    You are right about the textbox staying active, in this demo. I was shocked and had to try it again because in my app, when I click the button, then click the textbox, the exit event of the text box fires, then the enter event fires. So something unique about my app must be causing an additional level of processing beyond what you noted about the multipage being like a form within a form.
    You've convinced me there is no easy way around this and that other code is making things worse! I appreciate your help. I'll use this information to further analyze my app and find out what I can do to work around the problems.
    Thanks

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    I am not sure what you mean by "it doesn't fire when switching from one textbox to another".

    What doesn't fire? I got the enter/exit code of the textboxes to work exactly as expected when I when from one to the other while in the multipage. If I went outside the multipage (MP-exit) to one of the buttons, then went back to the multipage (MP -enter) it had kept whatever TB that was selected having the focus, and I then had to select the textbox desired.

    There is an "extra selection step" when working with multipage, as this must be entered before selecting an object on it.

    The way that the seem to work (and the events make sense in this view) is that of a "form within a form" Do whatever you want on the multipage before acknowledging the "big form". Perhaps you need an "OK" button on the multpage (and have the "big form buttons" disabled while on the multipage) and have the buttons enabled after "leaving the multipage".

    Steve

  8. #8
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    The multipage_Exit event doesn't fire when switching between TBs on the multipage.
    the extra OK button is an interesting idea, as is putting the buttons I have on the form, on the multipages.
    Thanks

  9. #9
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    I don't understand why you would expect the MP_exit to fire when changing between TB in your example.

    The 2 TBs are on the same multipage so you never exit the multipage...

    Steve

  10. #10
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    USA
    Posts
    223
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Event problems with Multipage (Excel 2000 sp3)

    I didn't expect it too, that was just by way of explanation. The combination of events we discussed is working fine now, thanks for your help.

Posting Permissions

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