I am trying to create a Union Query that will total the numbers from the months in 2010. I am trying to set it to display the month, the year, the type, and then the number input for that month, and then at the bottom display the "Grand Total" which adds all of the inputs. I have that set up with the following code:
Code:
Select Count(v.id) AS [Count#_], DatePart('yyyy',[date_entered]), AS Year_, DatePart('m',[date_entered]) AS Month_, DatePart('d',[date_entered]), AS Day_, [Visit_type] AS Visit_Type_
From tbl_recordsinput AS v
Group BY DatePart('yyyy',[date_entered]), DatePart('m',[date_entered]), DatePart('d',[date_entered]), [Visity_type]
Union SELECT Count(v.id) AS [Count#_], "Grand Total" AS Year_, "" AS Month_, "" AS Day_, "" AS Visit_Type
From tbl_recordsinput AS V
Group BY "", "", "", "",;
This code works just as it should. The catch I am running into is I am wanting it to prompt what visit type to display before the query is run, so I tried to add the line all in CAPS:
Code:
Select Count(v.id) AS [Count#_], DatePart('yyyy',[date_entered]), AS Year_, DatePart('m',[date_entered]) AS Month_, DatePart('d',[date_entered]), AS Day_, [Visit_type] AS Visit_Type_
From tbl_recordsinput AS v
Group BY DatePart('yyyy',[date_entered]), DatePart('m',[date_entered]), DatePart('d',[date_entered]), [Visity_type]
HAVING (((TBL_RECORDSINPUT.VISIT_TYPE)=[ENTER VISIT TYPE]))
Union SELECT Count(v.id) AS [Count#_], "Grand Total" AS Year_, "" AS Month_, "" AS Day_, "" AS Visit_Type
From tbl_recordsinput AS V
Group BY "", "", "", "",;
This will prompt me for the visit type before the query runs, but when the query displays the results it displays all results not the specific visit type I was wanting it to ONLY display. Is there a way to modify this code, so that the query will only display the numbers input from the visit type that I am telling the query to display?