Using form criteria to modifiy a report's results

psycoperl

Active Member
Joined
Oct 23, 2007
Messages
339
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. MacOS
  3. Web
I am trying to use a form that will launch a report based on the selection made by a user.

I have the following query as the recordsource for the report, and would like to have the user set the Site based on [Forms]![frmReporting].[cboCampus] in the line: HAVING (((qryAllData_ByDateSite.Site)=[Forms]![frmReporting].[cboCampus]))

I would like to do is that if a user picks from the form "All Sites" (which passes a value of '00') have all sites be displayed.

I cannot seem to get this to work, could someone please provide some guidance?

Thanks

Code:
SELECT DISTINCTROW Format$([qryAllData_ByDateSite].[ADate],'mmmm yyyy') AS ADate_Month, CLng(Nz(getfiscalyear([ADate]),0)) AS AYear,
 CLng(Nz(getfiscalmonth([ADate]),0)) AS aMonth, qryAllData_ByDateSite.Site, tblSite.siteDesc, tblSite.siteAbrv, 
Sum(qryAllData_ByDateSite.SumOfdelivQty) AS delivQty, 
Sum(qryAllData_ByDateSite.SumOfreadQty) AS readQty, 
Sum(qryAllData_ByDateSite.SumOfpackQty) AS packQty, 
Sum(qryAllData_ByDateSite.SumOfpickQty) AS pickQty
FROM tblSite INNER JOIN qryAllData_ByDateSite ON tblSite.siteID = qryAllData_ByDateSite.Site
GROUP BY Format$([qryAllData_ByDateSite].[ADate],'mmmm yyyy'), CLng(Nz(getfiscalyear([ADate]),0)),
  CLng(Nz(getfiscalmonth([ADate]),0)), qryAllData_ByDateSite.Site, tblSite.siteDesc, tblSite.siteAbrv,
  Year([qryAllData_ByDateSite].[ADate])*12+DatePart('m',[qryAllData_ByDateSite].[ADate])-1
HAVING (((qryAllData_ByDateSite.Site)=[Forms]![frmReporting].[cboCampus]))
ORDER BY CLng(Nz(getfiscalyear([ADate]),0)), CLng(Nz(getfiscalmonth([ADate]),0));
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,221,683
Messages
6,161,264
Members
451,692
Latest member
jmaskin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top