Results 1 to 3 of 3

Thread: Select value in list box at design-time

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    45

    Select value in list box at design-time

    I have 2 list boxes and another form.

    The first list box is lstparentcompanies, the 2nd lstchildcompanies.

    When I select lstparentcompanies, lstchildcompanies is populated with all of the child companies of that parent company.

    Fine that works.

    When I select lstchildcompanies the form is dynamically filled with data based on the lstchildcompanies. (bit o SQL).

    Fine that works.

    My problem is...in the form which holds lstchildcompanies data the data stays until my selection changes in lstchildcompanies.

    Normally this is fine, but the problem occurs when I change my lstparentcompanies selection.

    We have a new parent companies selected. lstchildcompanies populates with all new companies...but the form stays filled with old data from the previously selected child company.

    What I want to do is somehow make the child companies list box, by default, select the first value in its list. This will then force a refresh of the forms data.

    So when this happens, the form is populated with that child company's info, instead of waiting for the user to select a value in the lstchildcompanies.

    Is this clear enough?

    And no, selectfocus does not work, because it does not highlight or select a value, it just throughs a light square around a value which I can t key off of.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390
    lstchildcompanies.ListIndex = 0

    (if memory serves...i havent been using VB lately..been stuck in acces which handles listboxes differently..give it a shot)

    But, I would force the other form to clear.
    in the click of the parent companies...clear the data.
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  3. #3
    New Member
    Join Date
    Jan 2004
    Posts
    13
    As Static said, why not create a fuction to clear all the controls on the form (except the two listboxes obviously), and run that function when you change the parent company?

Posting Permissions

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



Click Here to Expand Forum to Full Width