You don't need a count or a dlookup. If it is a single select list box, you
need to set the subforms filter using the current value of the list box:
In the code below, please not that sfrmStuff is the name of the subform
control on the main form, not the name of the form being used in the subform
control. Also, all other names are made up:
If Not IsNull(Me.MyListBox) Then
Me.sfrmStuff.Form.Filter = "[Some Field] = '" & Me.MyListBox & "'"
Me.sfrmStuff.Form.FilterOn = True
End If
Now, if it happens the list box has multiple columns, you can use the list
box Column property to identify which column to use. Note the Column
property index starts at 0, so the first column in the list is .Column(0) and
the second is .Column(1), etc.
Me.sfrmStuff.Form.Filter = "[Some Field] = '" &
Me.MyListBox.Column(3) & "'"
--
Dave Hargis, Microsoft Access MVP
John Petty said:
As far as the number of items that would be in the listbox at any one time,
maybe 25-30 items. (This list box is designed to show all active projects (we
have a quick throughput time. Signoff is the only bottleneck)).
Also, this is not a multiselect list box.
I will see how well my coding skills work and try to create a counter and a
DLookup filter.
:
As I said before, you have to link the data in the subform to the data in the
master form using the fields in the tables. There is no way to link using
any kind of control.
You could filter the data, but depending how may rows are in your list box,
it may cause the form to appear slow.
Is this a multi select list box? If so, I can send you a function that will
return a string you can use for filtering (note, I have not used it for this
purpose, but it does work filtering a report)
--
Dave Hargis, Microsoft Access MVP
:
In short, I am trying to use the listbox to filter the data. If possible, I
am wanting to use this method throughout my app.
:
Dave,
Thanks for the response. I would have responded sooner but I had a calculus
class to attend.
That being said, I tried to set the master and child field links to tje
field names but to no avail. I get input boxes asking for the field
criteria, or when I link all fields in the listbox, I get an error stating
that I must have the same number of fields defined on both the Master and
Child link fields (and I do and in the same order).
I did forget to mention that I have the listbox on on tab control and the
subform on another. Could this be the problem? If so, how can I define the
code to link them together?
:
You don't use form controls in the link master and link child properties of
the subform control. Use the names of fields in the form and subform
recordsets.
--
Dave Hargis, Microsoft Access MVP
:
I have a listbox that is populated from a sub query (qyListFEA). I have set
the subform's LinkMasterField and LinkChildField to this listbox.
The list box contains 3 columns (Project Name, Project Number and Iteration).
When I select let's say Wheel 1, 5214, 1C, the subform only shows the Wheel
1 at iteration 1.
How can I get the data to synchronize so that if I select Wheel 1 at
iteration 1c or 2, etc. I can get the correct record to show?
Note: the sub query "qyListFEA" is based upon "qyFEA" which is where I need
the actual data from. If I use the master query in the listbox, I get a
bunch of ID's instead of the text.
Any help would be appreciated.