G
Guest
I have a database that has multiple "offices". Each "office" will have data
for multiple "years". Within each "year" there will be an "orginal estimated
completion date (OECD)". I want to find the greatest "OECD" for each "year"
and each "office".
I have created a series of queries which will return the correct
information, but I have hard-coded the values for "office" and "year"
(through 2012) in the queries.
I am looking for a VB way to do what I am doing through queries, because I
receive a message from Access stating it can't open anymore databases.
What I have so as queries:
This groups all the "OECD" into once Query for me.
SELECT [SAR Questions].FY, [SAR DATA].Office, [SAR DATA].[Original Estimated
Completion Date]
FROM [SAR Questions] INNER JOIN [SAR DATA] ON [SAR Questions].IEN = [SAR
DATA].[SAR Question]
GROUP BY [SAR Questions].FY, [SAR DATA].Office, [SAR DATA].[Original
Estimated Completion Date]
HAVING ((([SAR DATA].Office)="JMIS, Programs/Budget"));
This gives me the greatest "OECD for each year.
SELECT TOP 1 [SA Initial Completion Date Collection (Budget)].FY, [SA
Initial Completion Date Collection (Budget)].Office, [SA Initial Completion
Date Collection (Budget)].[Original Estimated Completion Date]
FROM [SA Initial Completion Date Collection (Budget)]
GROUP BY [SA Initial Completion Date Collection (Budget)].FY, [SA Initial
Completion Date Collection (Budget)].Office, [SA Initial Completion Date
Collection (Budget)].[Original Estimated Completion Date]
HAVING ((([SA Initial Completion Date Collection (Budget)].FY)=2006))
ORDER BY [SA Initial Completion Date Collection (Budget)].[Original
Estimated Completion Date] DESC;
Union
SELECT TOP 1 [SA Initial Completion Date Collection (Budget)].FY, [SA
Initial Completion Date Collection (Budget)].Office, [SA Initial Completion
Date Collection (Budget)].[Original Estimated Completion Date]
FROM [SA Initial Completion Date Collection (Budget)]
GROUP BY [SA Initial Completion Date Collection (Budget)].FY, [SA Initial
Completion Date Collection (Budget)].Office, [SA Initial Completion Date
Collection (Budget)].[Original Estimated Completion Date]
HAVING ((([SA Initial Completion Date Collection (Budget)].FY)=2007))
ORDER BY [SA Initial Completion Date Collection (Budget)].[Original
Estimated Completion Date] DESC;
....and so on for each year through 2012.
I have these two queries for each office, but when I try to join the second
query for all the offices together Access chokes.
My knoweldge of VB is about the same as a gnat, so dumb it down for me.
Thanks!!
for multiple "years". Within each "year" there will be an "orginal estimated
completion date (OECD)". I want to find the greatest "OECD" for each "year"
and each "office".
I have created a series of queries which will return the correct
information, but I have hard-coded the values for "office" and "year"
(through 2012) in the queries.
I am looking for a VB way to do what I am doing through queries, because I
receive a message from Access stating it can't open anymore databases.
What I have so as queries:
This groups all the "OECD" into once Query for me.
SELECT [SAR Questions].FY, [SAR DATA].Office, [SAR DATA].[Original Estimated
Completion Date]
FROM [SAR Questions] INNER JOIN [SAR DATA] ON [SAR Questions].IEN = [SAR
DATA].[SAR Question]
GROUP BY [SAR Questions].FY, [SAR DATA].Office, [SAR DATA].[Original
Estimated Completion Date]
HAVING ((([SAR DATA].Office)="JMIS, Programs/Budget"));
This gives me the greatest "OECD for each year.
SELECT TOP 1 [SA Initial Completion Date Collection (Budget)].FY, [SA
Initial Completion Date Collection (Budget)].Office, [SA Initial Completion
Date Collection (Budget)].[Original Estimated Completion Date]
FROM [SA Initial Completion Date Collection (Budget)]
GROUP BY [SA Initial Completion Date Collection (Budget)].FY, [SA Initial
Completion Date Collection (Budget)].Office, [SA Initial Completion Date
Collection (Budget)].[Original Estimated Completion Date]
HAVING ((([SA Initial Completion Date Collection (Budget)].FY)=2006))
ORDER BY [SA Initial Completion Date Collection (Budget)].[Original
Estimated Completion Date] DESC;
Union
SELECT TOP 1 [SA Initial Completion Date Collection (Budget)].FY, [SA
Initial Completion Date Collection (Budget)].Office, [SA Initial Completion
Date Collection (Budget)].[Original Estimated Completion Date]
FROM [SA Initial Completion Date Collection (Budget)]
GROUP BY [SA Initial Completion Date Collection (Budget)].FY, [SA Initial
Completion Date Collection (Budget)].Office, [SA Initial Completion Date
Collection (Budget)].[Original Estimated Completion Date]
HAVING ((([SA Initial Completion Date Collection (Budget)].FY)=2007))
ORDER BY [SA Initial Completion Date Collection (Budget)].[Original
Estimated Completion Date] DESC;
....and so on for each year through 2012.
I have these two queries for each office, but when I try to join the second
query for all the offices together Access chokes.
My knoweldge of VB is about the same as a gnat, so dumb it down for me.
Thanks!!