Combo Box - List Box

  • Thread starter Thread starter Dani Green via AccessMonster.com
  • Start date 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
 
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
 
Back
Top