Adnan
Ceate a combo, cmbBldg with the number you need, make that filed as
Bound
coloumn. If for example, you want the list box to show you only the
records
where tblWorkServiceOrders.[Bldg#]= The result of the combo. you need to
add
an expression in AfterUpdate events of the Combo *AND* in the OnCurrent
of
the *Form* , use Event Procedures.
The expression is:
Me.lstBldgs.RowSouce="SELECT tblWorkServiceOrders.Id,
tblWorkServiceOrders.[Bldg#],
tblWorkServiceOrders.WRNumber, tblWorkServiceOrders.POC,
tblWorkServiceOrders.DescriptionOfRequirements FROM tblWorkServiceOrders
WHERE
tblWorkServiceOrders.[Bldg#]=" & Me.cmbBldg
in Other words:
Me.lstBldgs.RowSource=" paste here what you have now in row source AND
add:
WHERE tblWorkServiceOrders.[Bldg#]=" & Me.cmbBldg
(the addition is *exactly* as I put it)
If your combo name is not "cmbBldg "chage the Me. expression at the end
to
your combo box name
Hope that that make sense
Regards
Adnan said:
JK,
I don't seam to implement this yet.
How about a create a cmbBldg that have as Row Source tblBldgs?
(tblBldgs
is
a table that has all the number I need).
Now, could I filter lstBldgs with with this cmbBldgs box
lstBldgs Row Source is:
SELECT tblWorkServiceOrders.Id, tblWorkServiceOrders.[Bldg#],
tblWorkServiceOrders.WRNumber, tblWorkServiceOrders.POC,
tblWorkServiceOrders.DescriptionOfRequirements FROM
tblWorkServiceOrders;
I appreciate your efforts JK!
Adnan
--
Please post all your inquiries on this community so we can all
benefit -
Thank you!
:
Adnan,
You must have a common field in both the combo and the list boxes. In
order
for it to work you need to tell Access how to filter the list box
depending
on what is in the combo. The usual way is :
cmbBuliding:
SELECT tblBldgs.Bldg, tblBldgs.[SomeField] FROM tblBldgs ORDER BY
[Bldg];
SELECT tblWorkServiceOrders.Id, tblWorkServiceOrders.WRNumber,
tblWorkServiceOrders.POC,
tblWorkServiceOrders.DescriptionOfRequirements,tblWorkServiceOrders.[SomeField],
FROM tblWorkServiceOrders
Only then we can limit the List box to show all the records that
[someField]
in the list box = [SomeFiled] in the combo.
However if you want to use the Bldg field in the combo you have to
tell
how
to restrict it in list box e.g.
tblBldgs.Bldg= what in the list box (or < or >= or whatever,)
Regards/JK
This is from Combo Box (cmbBldgs):
SELECT tblBldgs.Bldg FROM tblBldgs ORDER BY [Bldg];
And this is from the List Box (lstBldgs):
SELECT tblWorkServiceOrders.Id, tblWorkServiceOrders.WRNumber,
tblWorkServiceOrders.POC,
tblWorkServiceOrders.DescriptionOfRequirements
FROM
tblWorkServiceOrders;
Thank you JK!
Adnan
--
Please post all your inquiries on this community so we can all
benefit -
Thank you!
:
Andan,
Go to both your combo and list boxes, copy their Row Source from
their
respective Property sheets and paste them here. (they both start
with
the
word "SELECT")
Also tell me, for each of them, the bound column (a number) and
which
value
(field name) in your combo you want filter on in your list box. and
how
(e.g. =,>=,< etc )
Than I will be able to give you the *exact* syntax.
Regards/JK
JK, I appreciate your quick response,
I tried your code and it doesn't seam to work. I think I'm
missing
something
here. Let me try again being a little more clear:
My form name is......frmCosts
My combo box name is...cmbBldgs
My list box name is.....lstBldgs
My query name is.......qryForListBox
I need the Cambo box (cmbBldgs) to filter my List Box (lstBldgs)
after
Combo
Box's update. The List Box (lstBldgs) feeds from Query
(qryForListBox)
and
has these fields: WRNumber, POC and DescriptionOfWork
Again, thank you JK!
Adnan