Print Month?

  • Thread starter Thread starter Alex Martinez
  • Start date Start date
A

Alex Martinez

Hello,

I have form that displays various different kind of reports, all the user
needs to do is to press the correct command button to preview/print the
reports. My problem is I have data from previous months to current month.
How can I get the user to print previous or current month end data. For
example if I want to have the user to print out all of February 1 - 28, 2006
or March 1 -31, 2006 data how can I do that? I have a field called
"Completed" which I want to base it on. I know I can make some sort of
Parameter, but I don't want to have the user type "What is the begining
month" and "What is the Ending Month". I rather have the user input the
month end date for example 2/28/2006 to get all of Feburary "Completed"
date or 3/31/2006 for all of March "Completed date. Any tips or website to
visit will be appreciated. Thank you in advance.
 
I find it easiest to use forms to collect parameters. Your form could
present the user with a combo to choose a month and a textbox in which to
enter a year. You can use intelligent defaults that are set when the form
opens. For example, have the month default to the previous month and have
the year default to the current year (or the previous year if month is Dec).
Then the form has a button to run the report. In that button's click event,
you use the entered data to create the parameters to pass to the query:

Where Format(YourDate, "mmm") = Forms!YourForm!YourMonth AND
Format(YourDate, "yyyy") = Forms!YourForm!YourYear;

It's a little more complex when you want a range that spans more than a
single month. Then you will have to work out the last day of a month.
 
It'll probably be more efficient to use

WHERE YourDate BETWEEN DateSerial(Forms!YourForm!YourYear,
Forms!YourForm!YourMonth, 1) AND DateSerial(Forms!YourForm!YourYear,
Forms!YourForm!YourMonth + 1, 0)

That way, the DateSerial function only gets called twice for the entire
query, as opposed to the Format function getting called twice for every row
in the table.

(Of course, I'm assuming that Forms!YourForm!YourMonth holds a number
between 1 and 12, whereas you were assuming it held a 3 character
representation of the month)
 
STOP! You're both right(double mint commercial). The month could be a combo
so that it shows the month name but the bound field is numeric.
 
Back
Top