Results 1 to 5 of 5
  1. #1
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    710
    Thanks
    10
    Thanked 33 Times in 27 Posts

    Invalid Property Value (VBA/Word 2003 SP1)

    A little under a year ago, there was a thread starting with post <post#=365301>post 365301</post#> that covered this subject and I thought I had found a Get Out of Jail Free card.

    Here is the code I'm using, which is nearly identical to the code in the message that worked:
    <pre>Sub cmbAuthor_Exit(ByVal Cancel As MSForms.ReturnBoolean)
    If cmbAuthor.MatchFound = False Then
    MsgBox "Please choose a name from the list."
    cmbAuthor.Cancel = True
    With cmbAuthor
    .SelStart = 0
    .SelLength = Len(.Value)
    End With
    End If
    End Sub
    </pre>


    My problem is not that it doesn't work. It just doesn't pre-empt the MS Forms message "Invalid Property Value". That displays first, then the custom message box displays. I got the impression from the original thread that the custom box displayed in place of the MS Forms message. Was I mistaken, or should the MS Forms message not display?

    Thanks!
    Kim Murdock

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

    Re: Invalid Property Value (VBA/Word 2003 SP1)

    Instead of

    cmbAuthor.Cancel = True

    use

    Cancel = True

    You want to set the Cancel argument of the event procedure (the ByVal Cancel As MSForms.ReturnBoolean) to True, not the Cancel property of the control (which is meaningless for a combo box anyway, it is meant for command buttons; if Cancel is True, pressing the Escape key is equivalent to clicking the command button)

  3. #3
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    710
    Thanks
    10
    Thanked 33 Times in 27 Posts

    Re: Invalid Property Value (VBA/Word 2003 SP1)

    Hans,

    OK, that was silly.

    But even changing it doesn't pre-empt the MS Forms error message. (In fact, I was in error before, I never got the custom message to display -- that only happened while I was testing the msgbox itself.) So all I get is the Forms error -- and insistently -- until I change the value to something on the list.

    I probably shouldn't be doing this while asleep, but do you have any further insight? I have the following values set:
    MatchEntry = fmMatchEntryComplete
    MatchRequired = True

    Anything else I should check?

    Thanks!!
    Kim

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

    Re: Invalid Property Value (VBA/Word 2003 SP1)

    Since you want to handle a non-match yourself, you must set MatchRequired to False. If it is True, VBA throws up an error message before the On Exit event fires.

  5. #5
    5 Star Lounger kmurdock's Avatar
    Join Date
    Feb 2003
    Location
    Pacific Grove, California, USA
    Posts
    710
    Thanks
    10
    Thanked 33 Times in 27 Posts

    Re: Invalid Property Value (VBA/Word 2003 SP1)

    Of course. [Insert little emoticon of me slapping my forehead]

    Thank you Hans, it works perfectly now.

    Kim

Posting Permissions

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