473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Create a report based on Month

I have a table for tasked that have been done for a client. I need to run a report that lists all the tasks that were done in a specific month. I have been trying to find a way to set up a parameter query so that when I run the report a form would pop up and prompt me for the Month and the year. That would then pass the first and last day of that specific month to my date field in my query. Can anyone help me out with the coding. I have been searching for about 3 weeks and have not been able to find anything that would help.

Thanks, Robert
Apr 9 '08 #1
11 13261
Delerna
1,134 Expert 1GB
Hi ryonker and welcome

Is there any reason you want a form to pop up?
I ask because you could put criteria into the query that the report is based off.

The criteria would be in the form of a field that does not exist.
That way, when the report is opened the query will ask the user for the value of the field that dosn't exist.

So, assuming you have a year field and a month field you would do this.

Open the query in design mode.
In the criteria for the year enter [Please Enter The Year]
In the criteria for the month enter [Please Enter The Year]

Hopefully you don't have fields in the query called [Please Enter The Year]
or [Please Enter The Year] :-)
This means the query, when run will popup two message boxes and the values that are entered will be used as the criteria

I hope this makes sense and is of assistance to you
Apr 9 '08 #2
Delerna
1,134 Expert 1GB
By the way, you can also do it with a form.

You would have a textbox for each criteria on the form where the user enters the values.
The query that the report is based off would then link to those textboxes in the "criteria" for the relevant fields.

The easiest way to link to the forms textboxes is like this

1) Open the query in design mode
2) Put the cursor in the criteria for the field you want to link to a forms textbox
3) On the toolbar at the top of the query window, click the wand icon. tooltip is Build
4) Open the forms folder
5) Open the all forms folder
6) Click the form that has the textbox you want to link
7) In the middle pane double click the textbox you want to link


You should finish up with something like this in the criteria for the field
Expand|Select|Wrap|Line Numbers
  1. Forms![YourForm]![YourTextbox]
  2.  
You may or may not require the text property. I can't remember off hand
Like this
Expand|Select|Wrap|Line Numbers
  1. Forms![YourForm]![YourTextbox]Text 
  2.  
Experiment until you get it right. Putting the link to the textbox into a spare field so that it appears in the queries result when you run it will help you to see if its right or not.
Apr 9 '08 #3
By the way, you can also do it with a form.

You would have a textbox for each criteria on the form where the user enters the values.
The query that the report is based off would then link to those textboxes in the "criteria" for the relevant fields.

The easiest way to link to the forms textboxes is like this

1) Open the query in design mode
2) Put the cursor in the criteria for the field you want to link to a forms textbox
3) On the toolbar at the top of the query window, click the wand icon. tooltip is Build
4) Open the forms folder
5) Open the all forms folder
6) Click the form that has the textbox you want to link
7) In the middle pane double click the textbox you want to link


You should finish up with something like this in the criteria for the field
Expand|Select|Wrap|Line Numbers
  1. Forms![YourForm]![YourTextbox]
  2.  
You may or may not require the text property. I can't remember off hand
Like this
Expand|Select|Wrap|Line Numbers
  1. Forms![YourForm]![YourTextbox]Text 
  2.  
Experiment until you get it right. Putting the link to the textbox into a spare field so that it appears in the queries result when you run it will help you to see if its right or not.
Hi Delerna,

Thanks for the quick responses. I did it with the examples that you gave and have been able to get it to work correctly. Ideally what I would like to do is to have the user run the monthly tasks report. When it starts it would prompt them for a month that they would like the data from. The would then select February and the query would run and pull all the data that has a start date of 02/01/08 - 02/29/08. This is where I am getting lost. I know that the criteria in the query for the start date will have to begin with Between but I don't know how to specify that when the user selects February it should find the first day of February and the last day of February and then give me everything that is within those two dates.

I hope that this makes sense to you, its getting late and I have been staring at a monitor for a very long time and everything is starting to look the same.

Thanks for your help already and any more that you have.

Robert
Apr 9 '08 #4
Delerna
1,134 Expert 1GB
I will need an answer to a couple of questions in order to assist you further.

When the user selects a month Is it always going to be the current year?
The field that is to be used for the criteria is it a proper date field?

If the above are true you could use between.
But an easier way would be to check for records where the month of the date field = the month number entered by the user AND the year of the date field = the current year

so assuming the date field is called dte then where clause of the query will be something like

Expand|Select|Wrap|Line Numbers
  1. WHERE month(Dte)=Forms![YourForm]![YourTextbox]Text AND year(dte)=year(now())
  2.  
if you prefer to use between(), say so and I will help you get it right
Apr 9 '08 #5
I will need an answer to a couple of questions in order to assist you further.

When the user selects a month Is it always going to be the current year?
The field that is to be used for the criteria is it a proper date field?

If the above are true you could use between.
But an easier way would be to check for records where the month of the date field = the month number entered by the user AND the year of the date field = the current year

so assuming the date field is called dte then where clause of the query will be something like

Expand|Select|Wrap|Line Numbers
  1. WHERE month(Dte)=Forms![YourForm]![YourTextbox]Text AND year(dte)=year(now())
  2.  
if you prefer to use between(), say so and I will help you get it right
I tried you suggestion and I get an invalid syntax error (You may have entered an operand without an operator and it highlights TEXT before the AND.

In answer to your questions the field that is used for my criteria is a proper date field (##/##/####). The box where the user will select the date is a combo box that list the month in text (January, February...) Somehow I need to find a way to translate the word February to (Between 02/01/08 and 02/29/08) for example or if there is a different way with not using the Between function. Does this make sense?
Robert
Apr 9 '08 #6
Delerna
1,134 Expert 1GB
Can you open the query in design mode and go to SQL view and copy the SQL Code and post it here.
Apr 9 '08 #7
Can you open the query in design mode and go to SQL view and copy the SQL Code and post it here.
Here is the code:
Expand|Select|Wrap|Line Numbers
  1.  SELECT Tasks.Title, Tasks.[Active Status], Tasks.Priority, Tasks.Category, Tasks.Status, Tasks.[% Complete], Tasks.Description, Tasks.[Start Date]
  2. FROM Tasks
  3. WHERE (((Tasks.[Start Date]) Between DateSerial(Year(Date()),Month([Forms]![Form1]![cboMonth]),1) And DateSerial(Year(Date()),Month([Forms]![Form1]![cboMonth]),ReturnLastDateOfMonth(DateSerial(Year(Date()),Month([Forms]![Form1]![cboMonth]),1)))));
  4.  
I also have a module with the following code:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Function ReturnLastDateOfMonth(datDate As Date)
  3.     ReturnLastDateOfMonth = DateSerial(Year(datDate), Month(datDate) + 1, 0)
  4. End Function
  5.  
Hope that this is helpfull.
Apr 10 '08 #8
n8kindt
221 100+
i dont mean to throw a wrench in your thoughts here, but i had a similar situation and i handled it this way...
(enjoy the picture illustration) :)

i made a table called months and created a recordset for each month with an ID that corresponded with the month number



i used that as the record source for the first unbound combo box you see in my form. (as a cool little trick, notice i set the default date to automatically bring up the current month)



and finally, this is how i set up my query.



this worked like a charm for me. hopefully this well help u get going in the right direction.

cheers,
nate
Apr 10 '08 #9
Delerna
1,134 Expert 1GB
If you have done as nate suggested with the combo box, which I assumed you had then you query would be
Expand|Select|Wrap|Line Numbers
  1. SELECT Tasks.Title, Tasks.[Active Status], Tasks.Priority, Tasks.Category, Tasks.Status, Tasks.[% Complete], Tasks.Description, Tasks.[Start Date]
  2. FROM Tasks
  3. WHERE year(Tasks.[Start Date]) = Year(now()) and month(Tasks.[Start Date])=[Forms]![Form1]![cboMonth]);
  4.  
Also, nates query is just as legitimate. There is 1001 ways to skin a cat as the saying goes
By the way nate, cool post, a picture is worth a thousand words
Apr 10 '08 #10
n8kindt
221 100+
If you have done as nate suggested with the combo box, which I assumed you had then you query would be
Expand|Select|Wrap|Line Numbers
  1. SELECT Tasks.Title, Tasks.[Active Status], Tasks.Priority, Tasks.Category, Tasks.Status, Tasks.[% Complete], Tasks.Description, Tasks.[Start Date]
  2. FROM Tasks
  3. WHERE year(Tasks.[Start Date]) = Year(now()) and month(Tasks.[Start Date])=[Forms]![Form1]![cboMonth]);
  4.  
Also, nates query is just as legitimate. There is 1001 ways to skin a cat as the saying goes
By the way nate, cool post, a picture is worth a thousand words
thanks, delerna. and 1001 might be a little bit short ;-)
Apr 10 '08 #11
thanks, delerna. and 1001 might be a little bit short ;-)
Thanks for the ideas. I am going to try these now and will let you know if I have success. Thanks for all the help up to this point.
Apr 10 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Ken Fine | last post by:
I want my application to maintain a directory tree based on months and years, e.g.: 2004 January file file file February file
8
by: Donna Sabol | last post by:
First, I should start by saying I am creating a database to be used by some very impatient, non-computer literate people. It needs to be seameless in it's operation from their point of view. I...
1
by: Claude Alain | last post by:
Hello! We are a small non-profit organisation with about 400 members. We have created a database using Access97 which contains tombstone information on our members, including home adresses and...
2
by: neill dumont | last post by:
I've tried to be clear, but this still seems overly complex to me, but here goes: I have a report in front of an aggregate query. I have a single subreport based on the same query for both a...
18
by: PC Datasheet | last post by:
An Access user saw my name in a newsgroup and sent me a request for help on a project. As part of the project, a list of the dates in a month was needed. For anyone needing a list of dates in a...
9
by: rinmanb70 | last post by:
I have a table of transactions, some with past dates, some dated the current date, and some dated in the near future. On a report, I'm looking for a way to get four different sums using the...
12
by: Orchid | last post by:
Hello all, I have different version of reports which used for different months. For example, I am using report version 1 up to September, but we have some design changes on the report for October,...
5
by: martin DH | last post by:
I have a report with graphs, and this report retreives data from a table that is specified by a where-string-generating form (Access 2003). My problem: the graphs are based on the criteria...
8
by: Paul H | last post by:
I want to base a form on a crosstab query. The query shows statistics for a user defined period. The column headings will look something like this: ClientID Month01 Month02 Month03 etc.. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.