+ Reply to Thread
Results 1 to 18 of 18

Invalid property value in userform when values cleared from combobox

  1. #1
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Invalid property value in userform when values cleared from combobox

    I'm having a slight problem that I'm hoping someone can help me with. I have a userform that I've created, that seems to work fine.........one time! After data is submitted, I have cleared the combobox's values with this command:

    Please Login or Register  to view this content.
    etc

    which clears the values, but has the unintended consequence that the form becomes as sensitive as a 17 year old with their first hangover - if you click anywhere on the form, you get continuous 'invalid property value' dialog boxes popping up - I'm presuming because I set the combobox's property to 'exact match' (which I want), but that "" is NOT an exact match. One of the comboboxs is dependent on the other, and the rowsource looks up about 50 different named ranges, and adding "" to all of them seems like a convoluted solution.

    Is there a command for 'reset the combobox' after data submission, without offending the 'exact match' criteria? I've googled around but I can't find a solution. Even some code that prevents ANY keypress data entry would work (I think), because then I could remove the exact match property.

    Any thoughts or suggestions gratefully received, thank you.

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Invalid property value in userform when values cleared from combobox

    Set the ListIndex property to -1.

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: Invalid property value in userform when values cleared from combobox

    What cytop said.

    Or, alternatively you could add an IF statement to the combobox code that changes the rowsource for the other.
    Something like

    Please Login or Register  to view this content.
    BSB

  4. #4
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Invalid property value in userform when values cleared from combobox

    Quote Originally Posted by cytop View Post
    Set the ListIndex property to -1.
    I'm afraid that didn't work either - although again it did clear the values, I still get the same 'invalid property value' error message.

  5. #5
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Invalid property value in userform when values cleared from combobox

    Then something else is firing when the Listindex is changed and it refers to the ListIndex... probably. it's impossible to say without seeing the code/userform.

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

    Re: Invalid property value in userform when values cleared from combobox

    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.
    If posting code please use code tags, see here.

  7. #7
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Invalid property value in userform when values cleared from combobox

    Quote Originally Posted by Norie View Post
    Any chance you could upload a sample workbook?

    Click on GO ADVANCED and use the paperclip icon to open the upload window.
    Thank you all for your help, I'm afraid I don't think I can upload a sample workbook because it contains lots of intellectual property information and calculations with vlookups and named ranges etc, and if I stripped it all out the userform would probably be confusing and fairly meaningless.

    This is my userform code anyway, I appreciate that nobody has time to look through it all, but if there is something screamingly obvious. I have also realised that I have the same problem with my second userform, but that isn't surprising because it's the same butchered code I used for the first.

    Thank you all for trying anyway

    Please Login or Register  to view this content.

  8. #8
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: Invalid property value in userform when values cleared from combobox

    Do the named ranges that you're applying to ComboBox2 resemble the values that can be selected in ComboBox1?
    i.e. If ComboBox1's options were "Fruit", "Veg", "Meat". Do you have named ranges called the same?

    BSB

  9. #9
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Invalid property value in userform when values cleared from combobox

    Quote Originally Posted by BadlySpelledBuoy View Post
    Do the named ranges that you're applying to ComboBox2 resemble the values that can be selected in ComboBox1?
    i.e. If ComboBox1's options were "Fruit", "Veg", "Meat". Do you have named ranges called the same?

    BSB
    Mmmm, kinda, sorta, ish! (they do resemble, but not the same). I don't know if this was the most efficient way to do it (probably not), but I used the "case" thing, and basically said 'case combobox 1 = this, then the rowsource for combobox 2 = that'. The named ranges are quite similar, the options in combobox one are things like '1a blah blah blah blah', '4b la la la', then the named ranges are called 'a1', and 'b4' etc (coz the name for ranges can't start with a number).

  10. #10
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: Invalid property value in userform when values cleared from combobox

    Without sight of the workbook this is all guesswork, but perhaps something like adding the red text below would help?

    BSB

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Invalid property value in userform when values cleared from combobox

    Quote Originally Posted by BadlySpelledBuoy View Post
    Without sight of the workbook this is all guesswork, but perhaps something like adding the red text below would help?

    BSB

    Please Login or Register  to view this content.

    Thank you very much, I'll try that, although I'm not sure it's just the 'case' thing that's causing the problem, I think it might be affecting the other comboboxes too (not sure, the dialog box just seems to spring up when I click in any input box after adding data the first time). I will work this weekend on trying to strip out all information but leaving the functionality the same, I'm sooooo close to completing this project, and this is my first vba foray, just a few things to go! Thank you very much again for all your help, it is very, very much appreciated

  12. #12
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: Invalid property value in userform when values cleared from combobox

    Sorry if none of my suggestions help, but it really is difficult without being able to tinker with the workbook.

    Hope you get it all sorted soon. Good luck.

    BSB

  13. #13
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Invalid property value in userform when values cleared from combobox

    This is my workbook, I've stripped out all the confidential data (please god) which might have affected it slightly - I used Beatles songs instead, then couldn't remember all the ones I'd used! I removed all the vlookups and stuff coz they were redundant without the data. Anyway, I did try it, and the problem does seem to be the same. If anyone could tell me what to do, that would be extremely kind. Thank you everyone for your help.
    Attached Files Attached Files

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

    Re: Invalid property value in userform when values cleared from combobox

    How can we recreate the problem with the uploaded workbook?

  15. #15
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,511

    Re: Invalid property value in userform when values cleared from combobox

    Try changing the change event code for the first combobox to the code below and see if that does what you need.

    BSB

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Invalid property value in userform when values cleared from combobox

    Quote Originally Posted by Norie View Post
    How can we recreate the problem with the uploaded workbook?
    Oh sorry Norie, if you open one of the forms and fill out some information and hit the 'add' button, it'll say the data has been added, and it all works fine. But then if you click on the form again, 'invalid property value' dialog boxes keep popping up (I think because the properties in the comboboxes are not 'exact matches' after the information resets).

    Thanks BSB, I'll give that a go, have a long day ahead of me today I think

    Add: the more I look at it, the more obvious it is that the comboboxes 'resetting' is the problem - the forms work fine when first opened, it's only after data has been submitted, then cleared, that the comboboxs have 'invalid properties' if you click on them - and if I don't run the 'reset' code for the comboboxes, it all works, except of course that the comboboxes are left with the previously entered values after the other data is cleared. So basically after data has been submitted I need to find a way to reset the comboboxes to how they are when it's first opened.
    Last edited by bevc; 04-30-2016 at 03:43 AM.

  17. #17
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    1,016

    Re: Invalid property value in userform when values cleared from combobox

    Quote Originally Posted by bevc View Post

    Add: the more I look at it, the more obvious it is that the comboboxes 'resetting' is the problem - the forms work fine when first opened, it's only after data has been submitted, then cleared, that the comboboxs have 'invalid properties' if you click on them - and if I don't run the 'reset' code for the comboboxes, it all works, except of course that the comboboxes are left with the previously entered values after the other data is cleared. So basically after data has been submitted I need to find a way to reset the comboboxes to how they are when it's first opened.
    You can try adding the blue line:
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    04-01-2016
    Location
    England
    MS-Off Ver
    Excel 2010
    Posts
    56

    Re: Invalid property value in userform when values cleared from combobox

    I found a workaround, I added 'Select' to the first combobox, and then disabled the second combobox as per BSB's very helpful post. It's not a very elegant solution, but it seems to be working. Thank you very much everybody

+ 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. [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
  2. [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
  3. 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
  4. [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
  5. [SOLVED] Excel run-time error '381': Could not set the List property. Invalid property array index
    By eemiller1997 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-20-2012, 12:48 PM
  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