Change the query

Infinite

More left to learn.
Local time
Today, 10:55
Joined
Mar 16, 2015
Messages
402
Hello! I was wondering if its possible to change a query, using VBA.

I want to change this:

Code:
SELECT qryAdminEvents.EventID, tblShowSales.Item, Sum(tblShowSales.Quantity) AS SumOfQuantity, Sum(tblShowSales.[Gross Sales]) AS [SumOfGross Sales]
FROM tblShowSales INNER JOIN qryAdminEvents ON tblShowSales.EventID = qryAdminEvents.ShowNames
GROUP BY qryAdminEvents.EventID, tblShowSales.Item;


To this:

Code:
SELECT qryAdminEvents.EventID, tblShowSales.Item, Sum(tblShowSales.Quantity) AS SumOfQuantity, Sum(tblShowSales.[Gross Sales]) AS [SumOfGross Sales], tblShowSales.Date
FROM tblShowSales INNER JOIN qryAdminEvents ON tblShowSales.EventID = qryAdminEvents.ShowNames
GROUP BY qryAdminEvents.EventID, tblShowSales.Item, tblShowSales.Date;

Is that possible? And if so, how would I got about using that?
 
Sure, if appropriate. You'd change the SQL property of a DAO QueryDef. Searching on QueryDef should turn up the code.
 
Ok, I looked, and I cant find anything that is helping me.
 
Why don't you create two queries?

I want the user to be able to look at the all the sales, then at the click of a button, just look at the sales per day.
 
So create two forms based on the two SELECT statements and display whichever one is selected from the switchboard.
 

Users who are viewing this thread

Back
Top Bottom