Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List Boxes (2003)

    Hello there. Can you help a newbie? I've linked a list box to a table based on two fields - extract Id and PersonId. Person Id is the linking field as on the active form I'm wanting the List box to show extract Ids for the active person Id. I've tried selecting =[PersonId] in the SQL query at the back of the list box, but it keeps returning the full list. SQL below. What am I doing wrong??? Thanks for your input. Mazzer

    SELECT [tbl_PeopleData#].ExtractID, [tbl_PeopleData#].PersonID FROM [tbl_PeopleData#] WHERE ((([tbl_PeopleData#].PersonID)=[PersonId])) ORDER BY [tbl_PeopleData#].ExtractID;

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: List Boxes (2003)

    Welcome to Woody's Lounge!

    Try including a reference to the form:

    SELECT [tbl_PeopleData#].ExtractID, [tbl_PeopleData#].PersonID
    FROM [tbl_PeopleData#]
    WHERE ((([tbl_PeopleData#].PersonID)=[Forms]![NameOfForm]![PersonId]))
    ORDER BY [tbl_PeopleData#].ExtractID;

    where NameOfForm is the name of the form.
    You must update the row source when the user moves to a different record in the On Current event of the form:

    Private Sub Form_Current()
    Me.NameOfListBox.Requery
    End Sub

    where NameOfListBox is the name of the list box.
    If the user can change PersonID, you also need to update the combo box in the After Update event of PersonID:

    Private Sub PersonID_AfterUpdate()
    Me.NameOfListBox.Requery
    End Sub

  3. #3
    New Lounger
    Join Date
    Jul 2007
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List Boxes (2003)

    Thank you very much Hans will try this out.

Posting Permissions

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