Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Multipage - Cancel=True (Word 2000+)

    I can't think of a good (logical) reason for not allowing Cancel=True to be effective across a Multipage form,
    and yet it seems not to work (as I would like).

    A Multipage form, with 6 pages, has the "Cancel" and "Run" command buttons on the leftmost page (0 = Me.MultiPage1.Value).
    The command button cmdCancel has Cancel=True, and when that page has focus, the Escape key does what I'd expect it to do.
    From any other page (Me.MultiPage1.Value = 1,2,3,4,5) tapping the Escape key has no effect (except to frustrate the end-user).
    Presumably only visible keys can receive keyboard entries.
    To me this makes sense for all controls but one.

    Clearly typing "greaves" can and should have effect only in the currently selected text box on the active page.
    Likewise tapping the space bar ought to toggle only the active check box on the active page.
    The end-user doesn't want keyboarding to be doing weird things on pages hidden from view.

    The Cancel is different; it is unique. Amongst all the controls only one command button can have the Escape key assigned.
    Therefore tapping the Escape key must be, by definition, unambiguous.

    I can program my way around this, by detecting a change of page, and assigning Cancel=True to the cmdCancel(i) button on the newly current page,
    so there appears, to me, to be no sound reason for dis-allowing the practice of allowing Cancel=True to be effective across a Multipage form.
    <pre>Private Sub MultiPage1_Change()
    Select Case Me.MultiPage1.Value
    Case 0
    Me.cmdCancel0.Cancel = True
    Case 1
    Me.cmdCancel1.Cancel = True
    Case 2
    Me.cmdCancel2.Cancel = True
    Case 3
    Me.cmdCancel3.Cancel = True
    Case 4
    Me.cmdCancel4.Cancel = True
    Case 5
    Me.cmdCancel5.Cancel = True
    Case Else
    MsgBox "???"
    End Select
    End Sub</pre>


    (Unless, as is common, I've missed some nuance of VBA ....)

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Multipage - Cancel=True (Word 2000+)

    A simpler workaround is to place the cmdCancel button directly on the userform, outside the MultiPage control. The same goes for a command button with Default = True

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Multipage - Cancel=True (Word 2000+)

    <P ID="edit" class=small>(Edited by chrisgreaves on 10-Jun-08 05:56. Thoughts (1 day later))</P>>place the cmdCancel button directly on the userform, outside the MultiPage control.
    Like I said: Unless, as is common, I've missed some nuance of VBA ....
    Duh!
    My next question was going to be "Why is it called MultiPage1?"
    I suppose that when I created the Multipage control a couple of weeks back, I stretched it to make it all look tidy, fit the borders and all that.
    Since then my mind has been telling me that the Multipage control is the GUI form.
    Thanks Hans. I think I should go back to bed ....

    (1 day later)
    In retrospect I take solace in my original premise "I can't think of a good (logical) reason for not allowing Cancel=True to be effective across a Multipage form, ".
    That's true. I had hidden the functionality by my neatness. I'm glad that my logic, at any rate, is intact!

Posting Permissions

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