Filter a query based on a combobox in the form.

B

bizee

I have tried and tried, and searched and still cannot get this to
work. I also looked at a similar database created by our summer
intern, and it seems to work there. Seems to be that it should be
easy....... (I'm new to Access but pick up stuff quickly)

Main data resides in tbl_MasterData This is detailed cost
information at level 6 of the wbs.

I wanted to summarize that at level 5 of the wbs. There is a column
that has the level 5 value.

I created a simple form to test this. There is a combobox that ties
to another table called tbl_wbs5. This is a result of a query to get
only one row for each level 5. The result is 7 rows. The combo box
works fine. It only shows these 7 rows.

When I click on the button to run the Onclick event (qry_wbs5), It
works SOMEWHAT, in that I get data for all level 5's. At least it
works.

What I intended to do was to filter based on the combo box, the data
for ONE level 5, user choice.

When I go into qry_wbs5 and in the criteria box put: [Forms]!
[frm_wbs5]![wbs5] (wbs5 is the name of the combo box) I get an
error:

The MS Office database engine does not recognize '[Forms]![frm_wbs5]!
[wbs5]' as a valid field name or expression.

The qry_wbs only is looking at the tbl_masterdata. (as I said, it
will run but with all the data until I try to filter it.

The SQL view of this is:

TRANSFORM Sum(tbl_MasterData.Cost) AS [Sum Of Cost]
SELECT tbl_MasterData.WBS5
FROM tbl_MasterData
WHERE (((tbl_MasterData.WBS5)=[Forms]![frm_wbs5]![wbs5]))
GROUP BY tbl_MasterData.WBS5
PIVOT tbl_MasterData.Month;


The summer hire had a similar combobox, filter query. I see he has it
a little different: (his row that has the form filter statement)

SELECT [WBS Table].Tank, [Period Table].Year,
Sum(Master_Tank_Data.BCWS) AS SumOfBCWS, Sum(Master_Tank_Data.BCWP) AS
SumOfBCWP, Sum(Master_Tank_Data.ACWP) AS SumOfACWP
FROM [WBS Table] INNER JOIN ([Period Table] INNER JOIN
Master_Tank_Data ON [Period Table].PeriodID =
Master_Tank_Data.Period_Id) ON [WBS Table].WBS_ID =
Master_Tank_Data.WBS_ID
GROUP BY [WBS Table].Tank, [Period Table].Year
HAVING ((([WBS Table].Tank)=[forms]![frm_MainMenu]![lb_tank]))
ORDER BY [WBS Table].Tank, [Period Table].Year;
 

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