+ Reply to Thread
Results 1 to 5 of 5

Userform ComboBox Issue - Invalid Property Value

  1. #1
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    Userform ComboBox Issue - Invalid Property Value

    Hi All,

    I have an issue when trying to 'undo' last selection on a userform, when attempting to set the ListIndex of the last populated combobox to -1, when .MatchRequired = true.

    The basic steps are:


    1.Select item in ComboBox1 (BeforeUpdate copies ListIndex to the .Tag property to store as 'previous value'. ComboBox1 is then locked, ComboBox2 is then unlocked, focus moved to ComboBox2)
    2.Click on 'Undo' CommandButton (ComboBox2 is locked, ComboBox1 unlocked and ListIndex set to -1 if .Tag = vbnullstring or "")
    3.Invalid Property message is displayed

    I understand this is because -1 is not actually a value in the list to which MatchRequired refers. Is there a fix or valid workaround instead of adding "" as a ListItem.

    Thanks in advance

    Steve

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Userform ComboBox Issue - Invalid Property Value

    Untested in the absence of the workbook but try setting the Match required property to False then in the exit event of the combobox

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Userform ComboBox Issue - Invalid Property Value

    Steve

    Do you really need MatchRequired set to Yes?
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    Re: Userform ComboBox Issue - Invalid Property Value

    Hi Norie,

    It would be misleading for me to say Yes, when in fact the correct answer would be 'the user MUST be restricted to selecting a valid item from the ComboBox list', as subsequent ComboBoxes are dependent upon prior selections (they build SQL code with criteria to extract transactions from a datawarehouse). So in the absence of a fix where I can still use MatchRequired=True, I will set to false and add code to validate ListIndex selection is > -1. Not sure where at the moment as.....

    I have a ComboBox class module to handle the events, plus another Control class module to handle the events not available in the ComboBox class (eg OnEnter, OnBeforeUpdate, OnAfterUpdate & OnExit). I've only just looked at this and cannot get the OnBeforeUpdate to accept the argument "ByVal Cancel As MSForms.ReturnBoolean", though will look at the Change or Click events.

    I'll update when I've got it working. Thanks

  5. #5
    Registered User
    Join Date
    03-23-2011
    Location
    West Bromwich, England
    MS-Off Ver
    Excel 2007 & 2013 in Azure
    Posts
    83

    Re: Userform ComboBox Issue - Invalid Property Value

    Solved by setting MatchRequired = false, then check the value exists in the controls listindex, in it's BeforeUpdate event, cancelling the update if not.

    I couldn't get the cancel argument to work in the class (though I'm a novice with classes really) so used a standard control event in the Userform module.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Invalid property value in userform when values cleared from combobox
    By bevc in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-01-2016, 02:31 PM
  2. [SOLVED] Invalid use of property - passing Userform input to procedure
    By MeijdenB1977 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-11-2015, 04:03 AM
  3. [SOLVED] ComboBox - "Error: Invalid Property Used" while restricting the dropdown values
    By SunOffice in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-05-2013, 04:26 AM
  4. UserForm -> Combobox and it's RowSource property?
    By CEC in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-02-2013, 02:16 PM
  5. [SOLVED] userform invalid property value only on certain items in combobox
    By cfinch100 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-19-2013, 06:30 AM
  6. Rowsource property error in combobox userform
    By asha3010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2010, 08:06 AM
  7. Combobox returning invalid property error
    By duckboy1981 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2009, 05:24 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1