Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2005
    Posts
    18

    Unanswered: Listbox help please!!

    Im doing a library database with tables BOOKS and AUTHORS.

    There is a query called qry_search which has all the fields from the above tables.

    On my search form I have 2 listboxes (lst1 - which shows records from BOOKS) and (lst2 - which will show which authors have written which book when a book is chosen from lst1).

    I need to know how to get lst2 to show a books authors when a book is selected in lst1.

    Cheers

    ps I posted the same question earlier, but i dont think I explained it very well!!

  2. #2
    Join Date
    Jul 2004
    Location
    South Dakota
    Posts
    267
    In lst1, set it's RowSource to a query that contains all of the BookNames (make sure to include the Primary Key but you don't have to display it).

    Then in lst2, set it's RowSource to a query that is based on what is selected in lst1. Something like: "Select AuthorName From Authors Where BookID = Forms!MainForm!lst1" Assuming that the bound column in lst1 is the BookID.

    Then you need to add some code to lst1's click or double click event to requery lst2.

    Hope that helps.

    Canupus

  3. #3
    Join Date
    Jun 2003
    Location
    USA
    Posts
    1,032
    And (perhaps a similar answer with different words and an example) you can download a sample database at www.Bullschmidt.com/Access and open it up and notice that on the Invoices Dialog the Customer combo box on the search form is based on what was entered in the Rep combo box above it.

    This is done by the RowSource property of the Customer combo box's SQL statement. Also the OnEnter property of the Customer combo box runs a function which requeries itself:

    ' Dim var.
    Dim ctl As Control

    ' Set var.
    Set ctl = Screen.ActiveControl

    ' Requery control.
    ctl.Requery
    J. Paul Schmidt, Freelance Web and Database Developer
    www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

Posting Permissions

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