Query not picking up form values

A

Audrey1980

Hi,
I have a query to get the average margin per store for a particular week and
year.
If I hard code the week, year and store in the where clause this query
works, however if I actually use the form values it doesnt!
If I use the subquery only with the form values all is well.
Any ideas? I've tried breaking this into 2 seperate queries but getting the
same issue on the summary query...please help!!
Audrey

PARAMETERS [Forms]![Main Menu]![Store] Text ( 255 ), [Forms]![Main
Menu]![Year] Text ( 255 ), [Forms]![Main Menu]![Week] Text ( 255 );
SELECT dbo_Despatch_data_branch_summary.Branch AS Store,
Round(Avg([%$##@_Alias].[Input Margin]),2) AS [Avg Of Input Margin]
FROM [SELECT dbo_Despatch_data_branch_summary.Branch,
(([Extd_REV]-[Extd_WCEV])/[Extd_REV]) AS [Input Margin],
dbo_Despatch_data_branch_summary.Extd_WCEV,
dbo_Despatch_data_branch_summary.Extd_REV
FROM dbo_Despatch_data_branch_summary
WHERE (((dbo_Despatch_data_branch_summary.Year)= [Forms]![Main Menu]![Year])
AND ((dbo_Despatch_data_branch_summary.Week)= [Forms]![Main Menu]![Week]) AND
((dbo_Despatch_data_branch_summary.Branch)= [Forms]![Main Menu]![Store]))
GROUP BY dbo_Despatch_data_branch_summary.Branch,
dbo_Despatch_data_branch_summary.Extd_WCEV,
dbo_Despatch_data_branch_summary.Extd_REV
]. AS [%$##@_Alias]
GROUP BY dbo_Despatch_data_branch_summary.Branch;
 
K

KARL DEWEY

If dbo_Despatch_data_branch_summary.Year and
dbo_Despatch_data_branch_summary.Week are number fields then you might try
this --
WHERE (((dbo_Despatch_data_branch_summary.Year)= CLng([Forms]![Main
Menu]![Year])) AND ((dbo_Despatch_data_branch_summary.Week)=
CLng([Forms]![Main Menu]![Week])) AND
((dbo_Despatch_data_branch_summary.Branch)= CLng([Forms]![Main
Menu]![Store])))
 

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