R
romashka1
Guest
Hello everybody,
I'm relatively new to the Access and I never worked with VB or macros. I have the following problem:
Currently I have a table with the following info:
AgentNumber I StartDate I N200106 I N200105 I N200104 I ..... I N199501,
where in fields N199501 - N200106 I have payments for the appropriate month to the agents.
Having 6/2001 as current month I need to get a table with the information:
AgentNumber I 0MonthPayment I 1stMonthPayment I 2ndMonthPayment I .... I nmthMonthPayment, not to exceed 36 months
For example:
AgentNumber I StartDate I N200106 I N200105
1 5/15/01 100 150
should become
AgentNumber I 0MonthPayment I 1stMonthPayment
1 150 100
I figured out how to create a union query, but I would need to union 36 little queries..
Is there an easier way to do it?
Here is the actual query I made:
SELECT NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-0 AS NYLIC_yr, NEFYCDATA.N200106 AS payment
FROM NEFYCDATA INNER JOIN [date test] ON NEFYCDATA.AGT_NO = [date test].AGT_NO
WHERE ((([date test].nm) Between 0 And 36))
GROUP BY NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-0, NEFYCDATA.N200106;
union
SELECT NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-1 AS NYLIC_yr, NEFYCDATA.N200105 AS payment
FROM NEFYCDATA INNER JOIN [date test] ON NEFYCDATA.AGT_NO = [date test].AGT_NO
WHERE ((([date test].nm) Between 1 And 36))
GROUP BY NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-1, NEFYCDATA.N200105;
union and so on for 36 times...
Thank you!
I'm relatively new to the Access and I never worked with VB or macros. I have the following problem:
Currently I have a table with the following info:
AgentNumber I StartDate I N200106 I N200105 I N200104 I ..... I N199501,
where in fields N199501 - N200106 I have payments for the appropriate month to the agents.
Having 6/2001 as current month I need to get a table with the information:
AgentNumber I 0MonthPayment I 1stMonthPayment I 2ndMonthPayment I .... I nmthMonthPayment, not to exceed 36 months
For example:
AgentNumber I StartDate I N200106 I N200105
1 5/15/01 100 150
should become
AgentNumber I 0MonthPayment I 1stMonthPayment
1 150 100
I figured out how to create a union query, but I would need to union 36 little queries..
Is there an easier way to do it?
Here is the actual query I made:
SELECT NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-0 AS NYLIC_yr, NEFYCDATA.N200106 AS payment
FROM NEFYCDATA INNER JOIN [date test] ON NEFYCDATA.AGT_NO = [date test].AGT_NO
WHERE ((([date test].nm) Between 0 And 36))
GROUP BY NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-0, NEFYCDATA.N200106;
union
SELECT NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-1 AS NYLIC_yr, NEFYCDATA.N200105 AS payment
FROM NEFYCDATA INNER JOIN [date test] ON NEFYCDATA.AGT_NO = [date test].AGT_NO
WHERE ((([date test].nm) Between 1 And 36))
GROUP BY NEFYCDATA.AGT_NO, NEFYCDATA.PRODUCT_CD, [nm]-1, NEFYCDATA.N200105;
union and so on for 36 times...
Thank you!