• Invalid property value (VBA office97)

    Author
    Topic
    #382227

    Hi there

    In my form – I have a combo listbox with properties – styleDropDownCombo & Behaviour properties ‘match entry’ = 1 frmMatchEntryComplete.
    With my combo listbox – I load an array (with all the companys staff names).
    from the combo listbox – when I select a name it displays & all is OK.
    However in the listbox – if a name is displayed & I select the name & delete it & then hit the enter button/or goto another object on the form
    the following message is displayed: ‘Microsoft Forms – Invalid property value’. The only way to rid the error message is to actually go back to the listbox & select a name
    & this message displays I assume from the property MatchEntryComplete.
    I need to have the property ‘match entry’ = 1 frmMatchEntryComplete as there are approx 1200 names loaded & its just easier for the user to type the name & the name is displayed.
    Is there some code I can use to test if the listbox is blank or to handle the above scenario or work around it so the message isnt displayed?

    Diana

    Viewing 0 reply threads
    Author
    Replies
    • #647212

      How are you ‘deleting’ an item from the listbox. Are you building the listbox values with a Value list, and then rebuilding that value list through code? What I would recommend, is after the delete process, just set the listbox value to an index of 0, to have it jump to the first value. (You will have a problem with that if you can end up with NO values in your listbox.).

      Does that sort of answer your question?

      • #647463

        Hi Drew

        I’m deleting the particular item in the listbox -by choosing an item in the list>selecting the item & pressing the delete key.
        I’m building the listbox via code – an array which loads & displays in the listbox.
        When the listboxs actions are cmbContact_Change() – I have code stored in listboxs actions cmbContact_Change() that run codes to obtain intials etc.
        Thanks for you suggestion – I’ll try that & see how I go.

        Diana

        • #647464

          That is what I found curious. I built a listbox from code, and hitting the delete key did nothing. Are you capturing the key press event, to capture the delete key being pressed?

          • #652505

            Hi Drew
            how are you building a listbox via code? hardcoding the items in the listbox eg
            ‘load the ‘Closing’ array
            [cmbClosing].AddItem “Yours faithfully”
            [cmbClosing].AddItem “Yours sincerely”
            [cmbClosing].AddItem “Kind regards”
            [cmbClosing].AddItem “Best regards”
            [cmbClosing].AddItem “Warm regards”
            [cmbClosing].AddItem “Regards”

            this is how I’ve done it:
            the properties for my combo box are:
            MatchEntry = 1.fmMatchEntryComplete
            MatchRequired = True
            EnterFieldBehavior = 0.fmEnterFieldBehaviorSelectAll

            I have an array which contains all employee names, (approx 1200 names)
            when the form is initialised the array is loaded into the combo listbox via code ie

            ‘contact name
            ‘Load the Contact listbox and select the current one
            Load_Names ls_names(), “EMPLOYEE”
            ddlb_contact.Clear
            li_upper = UBound(ls_names)
            For i = 1 To li_upper
            ddlb_contact.AddItem
            li_pos = InStr(ls_names(i), vbTab)
            iStaffIndex = Val(Mid(ls_names(i), li_pos + 1))
            ddlb_contact.Column(0, i – 1) = Left(ls_names(i), li_pos – 1)
            ddlb_contact.Column(1, i – 1) = Mid(ls_names(i), li_pos + 1)
            If ls_str = StaffFullName(iStaffIndex) Or ls_str = staffsigningname(iStaffIndex) Then
            ddlb_contact.ListIndex = i – 1
            ls_Contact = ls_str
            End If
            Next
            ‘add the blank entry to Contact
            ddlb_contact.AddItem
            ddlb_contact.Column(0, i – 1) = “(None)”
            ddlb_contact.Column(1, i – 1) = “0”
            If ddlb_contact.ListIndex = -1 Then
            ddlb_contact.ListIndex = ddlb_contact.ListCount – 1
            End If

            when the form is displayed – the names are loaded in the listbox – you just select the current name displayed & hit the delete key & the name clears.
            No i’m not capturing any key press even to capture the delete key being pressed.
            hope this helps.
            please note: each time i paste code into a post, the indentations never come across, we have spoken about this before however I never did get this to work.
            Diana

            • #652511

              By setting MatchRequired = True, you are saying that the user cannot leave the combobox blank. Thus, deleting the selected entry from the combobox entry space and then exiting triggers a validation error. As the online help says:

              “If the MatchRequired property is True, the user cannot exit the ComboBox until the text entered matches an entry in the existing list.”

              P.S. You keep code indented in the Lounge by using the

               and 

              mark-up tags around your code.

            • #652683

              What application are you developing in?

            • #652756

              Thankyou JScher.

              The user requires that MatchRequired = True
              causing the validation error upon exit.
              The application developed in is Word97 VBA.
              Diana

            • #652766

              Maybe you can trap an event (maybe _Changed or _TryingToLeaveMe) for a blank field and show a Label above or below the ComboBox control saying: this item cannot be left blank. It would be nicer and a heck of lot more understandable than the pop-up error. I’m just not sure if you can intercept it before VB does…

            • #652779

              Aha….don’t program in Word very often, so I am not going to be much help on this…..

      • #683210

        Hi Hans

        I know its been awhile however I’ve only just picked up this project again.
        Just thought I’ld share with you how I fixed this issue using your suggestion as an idea.
        also Jefferson mentioned that I maybe to trap the error before VB intercepts & displays the unfriendly error message ‘Invalid property value’ & I was successful by using event Change()
        again thanks for you help.

        Diana

        Private Sub ddlb_StaffName_Change()
        Dim MsgboxResponse

        If ddlb_StaffName = “” Then

        ‘display message
        MsgboxResponse= MsgBox(“message to user here”,vbYesNo + vbInformation, “MsgboxTitle”
        If MsgboxResponse= vbYes Then ‘ user chose Yes.

        ddlb_StaffName.SetFocus
        SendKeys “%{Down}”
        Exit Sub

        Else ‘ user chose No.

        ddlb_StaffName= “(None)”
        If ddlb_StaffName.ListIndex = -1 Then
        ddlb_StaffNameListIndex = ddlb_StaffName.ListCount – 1
        End If
        OptAuthority.Value = True ‘set the other option button
        OptAuthority.SetFocus
        Exit Sub
        End If
        End If

        End Sub

    Viewing 0 reply threads
    Reply To: Invalid property value (VBA office97)

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

    Your information: