Combo Box - List Box

  • Thread starter Dani Green via AccessMonster.com
  • Start date
D

Dani Green via AccessMonster.com

I have a combo box that when clicked will filter records based on the
companyid.

On this same form, I have a list box. I need the list box to list only the
records based off the combo box AfterUpdate click, but my code is not
working. The combo is "Combo170" and the List is "List195". Here's my code:

Private Sub Combo170_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[Companyid] = " & Str(Nz(Me![Combo170], 0))
If Not rs.EOF Then Me.Bookmark = rs.Bookmark

Dim sFilter As String
sFilter = [CompanyName]


Me!Label90.Caption = sFilter
Me!List195.RowSource = [Companyid]

Me.List195.Requery

End Sub

Thanks for your help,
Dani
 
M

Michel Walsh

Hi,


Try a complete SQL statement for your row source, something like:

Me.List195.RowSource = "SELECT f1, f2, f3 FROM myTable WHERE CompanyID="
& Me.CompanyID


Hoping it may help,
Vanderghast, Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top