+ Reply to Thread
Results 1 to 16 of 16

Struggling with invalid property code

  1. #1
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Struggling with invalid property code

    I have a user form that the user can choose from 4 drop down boxes. They will be set so the user cannot leave them blank. There is a button on the form that then adds the data to a spreadsheet called Core Data.

    Please Login or Register  to view this content.
    I know its something to do with the clearing of the data to give a blank form. I'm sure I'm missing something staring at me in the face. Would anyone be able to point me in the right direction as I am a little new to this.


    Ultimately I wanted to have a button on a spreadsheet that calls the form, the user enters the data presses a "Add" button that writes the data back to the worksheet CoreData and then gives the user a blank form to try another line if they wished.


    Any help is greatly appreciated.

    Many thanks

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,282

    Re: Struggling with invalid property code

    You haven't said where the error occurs. My crystal ball is a little fuzzy today but suggests that you probably have another event (not shown) that is causing the issue.
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Struggling with invalid property code

    Quote Originally Posted by jancliff View Post
    I have a user form that the user can choose from 4 drop down boxes. They will be set so the user cannot leave them blank.

    I know its something to do with the clearing of the data to give a blank form.
    Without all the code and/or a sample its hard to give you a specific fix but I agree that this is the culprit.

    If you are really enforcing the fields/drop-downs to have an entry, the same rules apply to you, you cant clear them then unless you account for allowing this.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  4. #4
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Struggling with invalid property code

    Thank you so much for responding. I am very grateful.

    I get the error when I press the cmdbuttonAdd button, which has the code attached to as above. If I take out the code from clear the data ,

    Please Login or Register  to view this content.
    Without it, it doesn't clear the form obviously but I do not get the invalid property error so I am assuming it is within this section of code. Thank you for pointing me in the direction of the drop downs as I had set them to need a value. I will research around that area to see if I can get it to work. Thank you.

  5. #5
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,124

    Re: Struggling with invalid property code

    Do you have any change events eg
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Struggling with invalid property code

    No I dont have any change events. The only things i do have is code when the user form is activated.

    Please Login or Register  to view this content.
    Thank you for responding.

  7. #7
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Struggling with invalid property code

    Actualy - sorry thats not true I also have and AfterUpdate code on the cboType ;

    Please Login or Register  to view this content.
    sorry....

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,124

    Re: Struggling with invalid property code

    AfterUpdate is fine. But a Change event will fire when you clear the values, so I was thinking that may have been your problem

  9. #9
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Struggling with invalid property code

    I have uploaded the spreadsheet as i think I am getting confused..
    Attached Files Attached Files

  10. #10
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,124

    Re: Struggling with invalid property code

    It seems to be the cboType combo that's causing the problem, but not sure why.
    Try replacing it & see if that fixes the problem

  11. #11
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Struggling with invalid property code

    Easy approach is to simply unload and load the form:

    Comment out everything under "clear data" including the setfocus line. Then add:

    Please Login or Register  to view this content.
    This will accomplish basically what you want to achieve, a new clean form to fill in. The downside is that the form (for me anyway) pop's back to its designated location instead of where I had placed it.

    I think the long answer to your issue is how you are clearing the fields/controls. Its very likely that one or more of them require something other than "" to clear them. This could be something like xlNothing or some other property to clear it. I havent looked into it.

  12. #12
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Struggling with invalid property code

    That works a treat I hadn't thought of doing that fantastic thank you. I think it will work. I am trying to make sure the user cant leave a field blank at teh point of adding teh databut they can abandon their entries just by closing it. Ie a Close wont save but the add will (f that makes sense). Thanks again.

  13. #13
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Struggling with invalid property code

    I tried that but still got errors. I think I will do what Zer0Cool suggested as I think it may work ok for me - thank you so much for taking the time to have a look at it for me - I am super grateful

  14. #14
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,124

    Re: Struggling with invalid property code

    Does this work for you
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    12-02-2011
    Location
    Coventry, England
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Struggling with invalid property code

    I just need to work out how to correctly filter them because a user can skip the first drop down and the second dropdown seems to remember the values from the previous load of the form. I need to research the "refresh" for want of a better word. Thanks everyone for your help.

  16. #16
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Struggling with invalid property code

    The line causing the problem is (in the Private Sub CommandButtonAdd_Click()):

    Please Login or Register  to view this content.
    commented out the error does not occur. Not sure how to correct that, but that seems to be the cause of the issue

+ 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] code for listbox give could not set the list property . invalid property value
    By mazan2010 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2017, 10:22 AM
  2. [SOLVED] could not get the list property invalid argument - VBA Error code
    By chrismccarthy17 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-02-2016, 11:23 AM
  3. Runtime error 381: Could not set the list property.Invalid property array index
    By rohith4prithvi in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-23-2014, 10:24 PM
  4. [SOLVED] Compile Error: Invalid Use of Property on stupidly simple code
    By QueeniePie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-18-2013, 11:41 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. Replies: 2
    Last Post: 06-11-2012, 03:03 PM
  7. Code error “wrong number of arguments or invalid property assignment”
    By hattrick_123a in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-19-2011, 06:16 PM

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