+ Reply to Thread
Results 1 to 12 of 12

loading ListBox row items to another UserForm

  1. #1
    Registered User
    Join Date
    02-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    loading ListBox row items to another UserForm

    It might be eayser if I post all the code here, this first part is Userform4 which does the searching of my data and sets up the results in the listbox as well as performs the listbox selection of a row and then launches userform5 which is the code that's giving me issues. I am getting the error "object Variable or with block variable not set" and the code stops with this line highlighted
    Please Login or Register  to view this content.

    This is UserForm4 getting error as indicated in Red

    Please Login or Register  to view this content.
    This is UserForm5 that has a bunch of TextBox and ComboBox controls to be populated from the Userform4 listbox once launched.

    Please Login or Register  to view this content.

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

    Re: loading ListBox row items to another UserForm

    The line of code you highlight probably isn't where the error is.

    The error is more likely to be in the Initialize of UserForm5.

    To find it goto Tools>Options and on the General tab change to either Break on Error in Class Modules or Break on all Errors.

    Might be worth attaching the workbook.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: loading ListBox row items to another UserForm

    Your right about attaching the file, as I still can't this to work, I hope this helps if you can resolve this one, I have been on this for days and just can't get it.
    Attached Files Attached Files

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

    Re: loading ListBox row items to another UserForm

    You haven't set rMyData to anything in the UserForm5 module so you get an error here.
    Please Login or Register  to view this content.
    You do declare it and set it to refer to a range in the sub for the search button on UserForm4, but it won't be visible outside that sub.

  5. #5
    Registered User
    Join Date
    02-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: loading ListBox row items to another UserForm

    It's still not liking that, perhaps I am missing the boat on where to declare it

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

    Re: loading ListBox row items to another UserForm

    What did you try?

    You have declared it, just not set it to refer to anything.


    What should it refer to?

  7. #7
    Registered User
    Join Date
    02-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: loading ListBox row items to another UserForm

    I put it here in UserForm5

    Please Login or Register  to view this content.

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

    Re: loading ListBox row items to another UserForm

    I thought you'd changed something?

    You need to set rMyData to refer to a range.

    In the other code you do that here.
    Please Login or Register  to view this content.
    What are you trying to populate the textboxes with anyway?

    Is it the data from the selected row on UserForm4?
    Please Login or Register  to view this content.
    Last edited by Norie; 12-27-2012 at 01:53 AM.

  9. #9
    Registered User
    Join Date
    02-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: loading ListBox row items to another UserForm

    yes that's it I am trying to populate the UserForm5 textBoxes with the row data in the ListBox1 on UserForm4

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

    Re: loading ListBox row items to another UserForm

    That's what that last piece of code I posted does.

  11. #11
    Registered User
    Join Date
    02-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: loading ListBox row items to another UserForm

    Resolved!!

    Thank you for the help, I had been trying so many things I cant remember what I tried first or last, But this is the resluting code that now works and I could not have gotten her without your help

    Please Login or Register  to view this content.

  12. #12
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: loading ListBox row items to another UserForm

    thank you for posting the resolution :-) please don't forget to mark the thread solved
    Josie

    if at first you don't succeed try doing it the way your wife told you to

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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