CoffeeGuru
Registered User.
- Local time
- Today, 20:42
- Joined
- Jun 20, 2013
- Messages
- 121
I have a grouped query that returns a list of all periods
qryPeriod
Year | Week | Period
2013 | 48 | 2013 - 48
2013 | 49 | 2013 - 49
2013 | 50 | 2013 - 50
2013 | 51 | 2013 - 51
2013 | 52 | 2013 - 52
2014 | 1 | 2014 - 01
2014 | 2 | 2014 - 02
2014 | 3 | 2014 - 03
2014 | 4 | 2014 - 04
I want to work out what the last period - 1 is (2014 - 03)
I want to work out what the last period - 4 is (2013 - 52)
I want to work out what the last period - 6 is (2013 - 50)
I want to work out what the last period - 8 is (2013 - 48)
these are then used as the start of a between lookup against [tblMaster] along with the last record in the qryPeriod (2014 - 04)
I am guessing that I will need 4 queries so If someone can sort out last period - 8 I can probably do the others.
Question: would DLookUp do this say return the last 4 values, Last 6 Values and Last 8 Values
qryPeriod
Code:
SELECT [tblMaster].Year, [tblMaster].Week, ([Year] & " - " & Right(0 & [Week],2)) AS Period
FROM [tblMaster]
GROUP BY [tblMaster].Year, [tblMaster].Week, ([Year] & " - " & Right(0 & [Week],2));
Year | Week | Period
2013 | 48 | 2013 - 48
2013 | 49 | 2013 - 49
2013 | 50 | 2013 - 50
2013 | 51 | 2013 - 51
2013 | 52 | 2013 - 52
2014 | 1 | 2014 - 01
2014 | 2 | 2014 - 02
2014 | 3 | 2014 - 03
2014 | 4 | 2014 - 04
I want to work out what the last period - 1 is (2014 - 03)
I want to work out what the last period - 4 is (2013 - 52)
I want to work out what the last period - 6 is (2013 - 50)
I want to work out what the last period - 8 is (2013 - 48)
these are then used as the start of a between lookup against [tblMaster] along with the last record in the qryPeriod (2014 - 04)
I am guessing that I will need 4 queries so If someone can sort out last period - 8 I can probably do the others.
Question: would DLookUp do this say return the last 4 values, Last 6 Values and Last 8 Values
Last edited: