• Invalid Property Value (VBA/Word 2003 SP1)

    Home » Forums » AskWoody support » Productivity software by function » Visual Basic for Applications » Invalid Property Value (VBA/Word 2003 SP1)

    Author
    Topic
    #416376

    A little under a year ago, there was a thread starting with post post 365301 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:

    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
    

    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

    Viewing 0 reply threads
    Author
    Replies
    • #931284

      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)

      • #931291

        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

        • #931292

          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.

          • #931295

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

            Thank you Hans, it works perfectly now.

            Kim

    Viewing 0 reply threads
    Reply To: Invalid Property Value (VBA/Word 2003 SP1)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: