D
Den
Group:
I'm new to Access - and am sure that there is a way to achieve what I want
.... I just don't know how ... your help would be appreciated.
I'll simplify the problem that I have for ease of clarity!
Using specifics .....
During this year (say '04) I need my report to print data from table
fields F04,F05,F06,F07,F08,F09.
During next year (say '05) I need my report to print data from table
fields F05,F06,F07,F08,F09,F10.
During the year after (say '06) I need my report to print data from table
fields F06,F07,F08,F09,F10,F11.
In the general case ...
During the year n (n<='04) I need my report to print data from table
fields Fn,Fn+1,Fn+2,Fn+3,Fn+4,Fn+5.
My solution has been (for '04) to set the report recordsource as:
SELECT F04 AS C1, F05 AS C2, F06 AS C3, F07 AS C4, F08 AS C5, F09 AS C6
FROM TABLE;
and to then create my report using the SQL aliaii C1,C2,C3,C5,C5,C6. This
works.
At the end of the year, all I need to do is to change the SQL statement in
the report recordsource. However, I really need to automate this.
What I'd like to do is to be able to put the report recordsource SQL in as a
string ... like this:
="SELECT F"&right(year(date()),2)&" AS C1, F"&right(year(date())+1,2)&" AS
C2, F"&right(year(date())+2,2)&" AS C3, F"&right(year(date())+3,2)&" AS C4,
F"&right(year(date())+4,2)&" AS C5, F"&right(year(date())+5,2)&" AS C6 FROM
TABLE;" ... okay inelegant but it should do the job ... but Access doesn't
want to know.
My guess is that I am on the right tracks, but I'm missing a step or
something. How do I dynamically set the report recordsource from a string?
Could any wise person out there point me in the correct direction.
Cheers
D
I'm new to Access - and am sure that there is a way to achieve what I want
.... I just don't know how ... your help would be appreciated.
I'll simplify the problem that I have for ease of clarity!
Using specifics .....
During this year (say '04) I need my report to print data from table
fields F04,F05,F06,F07,F08,F09.
During next year (say '05) I need my report to print data from table
fields F05,F06,F07,F08,F09,F10.
During the year after (say '06) I need my report to print data from table
fields F06,F07,F08,F09,F10,F11.
In the general case ...
During the year n (n<='04) I need my report to print data from table
fields Fn,Fn+1,Fn+2,Fn+3,Fn+4,Fn+5.
My solution has been (for '04) to set the report recordsource as:
SELECT F04 AS C1, F05 AS C2, F06 AS C3, F07 AS C4, F08 AS C5, F09 AS C6
FROM TABLE;
and to then create my report using the SQL aliaii C1,C2,C3,C5,C5,C6. This
works.
At the end of the year, all I need to do is to change the SQL statement in
the report recordsource. However, I really need to automate this.
What I'd like to do is to be able to put the report recordsource SQL in as a
string ... like this:
="SELECT F"&right(year(date()),2)&" AS C1, F"&right(year(date())+1,2)&" AS
C2, F"&right(year(date())+2,2)&" AS C3, F"&right(year(date())+3,2)&" AS C4,
F"&right(year(date())+4,2)&" AS C5, F"&right(year(date())+5,2)&" AS C6 FROM
TABLE;" ... okay inelegant but it should do the job ... but Access doesn't
want to know.
My guess is that I am on the right tracks, but I'm missing a step or
something. How do I dynamically set the report recordsource from a string?
Could any wise person out there point me in the correct direction.
Cheers
D