I mocked up your tables.
ID |
CPA Pretty WELL ID |
mmmdate |
qryRank |
jid |
1171 |
100/01-01-034-04w5/00 |
01/06/2014 |
1 |
1 |
1171 |
100/01-01-034-04w5/00 |
01/07/2014 |
2 |
2 |
1171 |
100/01-01-034-04w5/00 |
01/08/2014 |
3 |
3 |
1171 |
100/01-01-034-04w5/00 |
01/09/2014 |
4 |
4 |
1171 |
100/01-01-034-04w5/00 |
01/10/2014 |
5 |
5 |
3045 |
100/01-01-041-06w5/00 |
01/10/2012 |
1 |
6 |
3045 |
100/01-01-041-06w5/00 |
01/11/2012 |
2 |
7 |
Note the PRD values below are totally fictitious since they aren't part of the Ranking issue.
CPA Pretty Well ID |
mDate |
PRD Monthly GAS e3m3 |
PRD Monthly OIL m3 |
PRD Monthly WTR m3 |
PRD Monthly CND m3 |
PRDMonthly HRS hrs |
RankSS |
jjid |
100/01-01-034-04w5/00 |
01-06-2014 |
11 |
22 |
33 |
44 |
55 |
|
1 |
100/01-01-034-04w5/00 |
01-07-2014 |
12 |
23 |
34 |
45 |
56 |
|
2 |
100/01-01-034-04w5/00 |
01-08-2014 |
13 |
24 |
35 |
46 |
57 |
|
3 |
100/01-01-034-04w5/00 |
01-09-2014 |
14 |
25 |
36 |
47 |
58 |
|
4 |
100/01-01-034-04w5/00 |
01-10-2014 |
15 |
26 |
37 |
48 |
59 |
|
5 |
100/01-01-041-06w5/00 |
01-10-2012 |
16 |
27 |
38 |
49 |
60 |
|
6 |
100/01-01-041-06w5/00 |
01-11-2012 |
17 |
28 |
39 |
50 |
61 |
|
7 |
Your table t5Rankings is Ranked based on your ID and mmmDate, but since ID is used for the same grouping as
CPA Pretty WELL ID, I created a unique composite index based on
-CPA Pretty WELL ID and mmmDate and used the related fields in 5_ProductionModule to make another unique composite index --namely CPA Pretty WELL ID and mDate. (see attached graphic)
Next was to create an update query that joined the tables on these indexed fields, update the 5_ProductionModule.RankingSS with the related values from t5Rankings.QryRank
The query SQL:
Code:
UPDATE 5_ProductionModule INNER JOIN t5Rankingss
ON ([5_ProductionModule].mDate = t5Rankingss.mmmdate) AND
([5_ProductionModule].[CPA Pretty Well ID] = t5Rankingss.[CPA Pretty WELL ID])
SET [5_ProductionModule].RankSS = [t5Rankingss]![qryRank];
The final result is
CPA Pretty Well ID |
mDate |
PRD Monthly GAS e3m3 |
PRD Monthly OIL m3 |
PRD Monthly WTR m3 |
PRD Monthly CND m3 |
PRDMonthly HRS hrs |
RankSS |
jjid |
100/01-01-034-04w5/00 |
01-06-2014 |
11 |
22 |
33 |
44 |
55 |
1 |
1 |
100/01-01-034-04w5/00 |
01-07-2014 |
12 |
23 |
34 |
45 |
56 |
2 |
2 |
100/01-01-034-04w5/00 |
01-08-2014 |
13 |
24 |
35 |
46 |
57 |
3 |
3 |
100/01-01-034-04w5/00 |
01-09-2014 |
14 |
25 |
36 |
47 |
58 |
4 |
4 |
100/01-01-034-04w5/00 |
01-10-2014 |
15 |
26 |
37 |
48 |
59 |
5 |
5 |
100/01-01-041-06w5/00 |
01-10-2012 |
16 |
27 |
38 |
49 |
60 |
1 |
6 |
100/01-01-041-06w5/00 |
01-11-2012 |
17 |
28 |
39 |
50 |
61 |
2 |
7 |
Note: The extra fields jjId and Jid were added by me and made PK of the table. They don't play into the actions above.
I hope this is useful.