Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2009
    Posts
    39

    Unanswered: Select values from combo box, populate list box based on combo box value

    I have a form called FRMDelinquent, this form is used to search records from the Delinquent_Assessment table. This table can have multiple records for the same property owner if the property owner has delinquent assessments for multiple years, a record is made for each assessment year, I.E John Doe 35 main street 2010, John Doe 35 main street 2012.

    In FRMDelinquent there is a combo box (OwnerNamecb) thats populated with distinct owner names from Delinquent_Assessment table. What I'm trying to do is when a user selects an owner name from OwnerNamecb, a list box (yearlb) will be populated with each year the selected owner name has had a delinquent assessment.

    I'm able to do this using a text box, but it only displays one year in the text box so if the owner has had multiple years of delinquent assessments it doesn't display all years.

    Heres my code that im using to populate the year in the text box.

    Private Sub Ownernamecb_AfterUpdate()

    YEARBX = DLookup("[assessed_year]", "[delinquent_assessment]", _
    "[ownername]='" & [ownernamecb] & " ' ")
    End Sub

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    With the Listbox properly initialized (number of columns, width of the columns, etc...):
    Code:
    Private Sub Ownernamecb_AfterUpdate()
    
        Dim strSQL As String
    
        strSQL = "SELECT <Comma-separated List of Columns> " & _
                 "FROM delinquent_assessment " & _
                 "WHERE ownername = '" & Me.Ownernamecb.Value & "'"   
        Me.<ListBoxName>.RowSource = strSQL
    
    End Sub
    Have a nice day!

  3. #3
    Join Date
    Jul 2009
    Posts
    39
    Thank you Sinndho. Your solution worked perfectly.

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome!
    Have a nice day!

Posting Permissions

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