+ Reply to Thread
Results 1 to 7 of 7

userForm assigning values

  1. #1
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    userForm assigning values

    Howdy, again:

    When starting up my UserForm, I'm trying to set a value within a listBox, using a command like userForm1.lbSelectDriver.value = "Bob". That selection is within the list data so the listBox shows "Bob" when the form is displayed. However, to make the selection "valid", it seems that I have to enter the listBox and "jiggle" the selection (move the cursor to a different selection and then back to the one I want). Should I be setting the desired value on the basis of listIndex? If so, how?

    Any thoughts.

    TIA.

    Bob
    Last edited by bstubbs; 07-29-2009 at 12:44 PM.

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: userForm assigning values

    Where exactly are you using that code?
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: userForm assigning values

    I load the userForm, set the values that I want and then show. Is that what you mean?

    Bob

  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: userForm assigning values

    It was the specific code I was after really. From what you describe, it ought to work.

  5. #5
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: userForm assigning values

    Here's the code:

    Please Login or Register  to view this content.
    I'm pulling a "record" from the worksheet, putting the data into the userForm and allowing the user to further edit the data.

    Bob

  6. #6
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: userForm assigning values

    Do any of the listboxes work properly? Do their change events affect each other? Are they bound to ranges on the worksheet?

  7. #7
    Forum Contributor
    Join Date
    01-09-2009
    Location
    Cedar Hill, Tx
    MS-Off Ver
    Excel 2003
    Posts
    200

    Re: userForm assigning values

    In looking at which fields come over ok and those that didn't, there was nothing in the listBox definitions that would cause some to work and some not. I changed the code, however, to first "setFocus" and then setting the desired value and it worked fine, consistently. Although this solves the problem, should that point me in some direction as to why some worked and some didn't?

    Thanks.

    Bob

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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