Question : creating a complicated report in access

I am working on creating a report for a MS Access database and I am not very experienced with either access or SQL. Here are the requirements for the report:

The report will be pulling quarterly data from the database.
When the report is generated, it needs to pull data for the current quarter and also some historical data from previous quarters that is stored in a table.

Now I know how to write queries to pull counts of data for the report, but my problem is how to create the report just for a quarter? This is a report that will change quarterly, so I cannot hard code certain dates in the report. Here is some pseudocode that I wrote trying to explain this better:

get the current date
determine which quarter the date falls in, 1, 2, 3, or 4
look at the stat report table and see if the previous quarter is in the table
  if it is not then generate the data for the previous quarter and put it in the table
if it is in the table then generate current data for the current quarter and output the report by:
  knowing the current quarter we can determine the start date of the quarter and look for
  all records from the start date on.

Any help would be appreciated, thanks.

Answer : creating a complicated report in access

Access has a function to determine the quarter:
Format(Date(),"q")
will give you the current date's quarter number (1-4).

To get data for the current quarter, you could use:
SELECT * FROM MyTable WHERE Format([MyDateField],"q") = Format(Date(),"q") AND Year([MyDateField]) = Year(Date())

To get data for the previous quarter is a little more complex but we can do it just by deducting 3 months from the current date (since we know this will definitely be in the previous quarter):
SELECT * FROM MyTable WHERE Format([MyDateField],"q") = Format(DateAdd("m",-3,Date()),"q") AND Year(DateAdd("m",-3,Date())) = Year(DateAdd("m",-3,Date()))
Random Solutions  
 
programming4us programming4us