473,394 Members | 2,048 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,394 software developers and data experts.

Grouping in Access Report

I am writing a database for sales forecasting. All of my entries are
in a table, each entry has a Projecting Booking Date. I need to write
a report with 4 groupings:

0-30 Days Out
31-60 Days Out
61-90 Days Out
Over 90 Days Out

How do I set this up in my report? Do I need to write sub-reports for
each grouping and then combine them all on one report, or is there an
easier way to create these groups on a report?

Feb 15 '06 #1
4 1799
ia**********@hermanmiller.com wrote:
I am writing a database for sales forecasting. All of my entries are
in a table, each entry has a Projecting Booking Date. I need to write
a report with 4 groupings:

0-30 Days Out
31-60 Days Out
61-90 Days Out
Over 90 Days Out

How do I set this up in my report? Do I need to write sub-reports for
each grouping and then combine them all on one report, or is there an
easier way to create these groups on a report?


Ian I do something quite similar in reports which show work backlogs
and, in fact, use the same groupings (plus another one for more than 365
days).

Presumeably, you are getting this information from a table which has a
booking date, which, for the example below, I'll refer to as
WO_REQUEST_DATE (since that allows me to paste soemthing out of my own
work!). In your report recordsource or the query that is the source for
your report, create a calculted expression similar to the one below
(substitute your field name for WO_REQUEST_DATE, of course!):

Projected_Date: Switch(DateDiff("d",[WO_REQUEST_DATE],Date())<=30,"0-30
Days Out",DateDiff("d",[WO_REQUEST_DATE],Date())<=60,"31-60 Days
Out",DateDiff("d",[WO_REQUEST_DATE],Date())<=90,"61 to 90
Days",DateDiff("d",[WO_REQUEST_DATE],Date())>90,"Over 90 Days Out")

Remember that the switch function evaluates in order as you write the
conditions, so it's not necessary to use "and" or between in the
conditions for 31-60 Days Out and 61-90 Days Out.

In your report, use groupings and headers (which I'm assuming you're
familiar with) and set Projected_Date as the first Field/Expression.

There ya go...
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Feb 15 '06 #2
Hey Tim, what does the "d" do in your code?

I copied and pasted your string exactly, then substituded
[WO_REQUEST_DATE] for [BookingDate] which is my date field. I created
a new query based on my table, and posted this to create a new
calculated field. It immediately gives me an error saying I have
invalid syntax, and when I hit "Okay" it highlights the "d". Here's my
code:

Projected_Date: Switch(DateDiff("d",[BookingDate],Date())<=30,"0-30
Days Out",DateDiff("d",[BookingDate],Date())<=60,"31-60 Days
Out",DateDiff("d",[BookingDate],Date())<=90,"61 to 90
Days",DateDiff("d",[BookingDate],Date())>90,"Over 90 Days Out")

Feb 15 '06 #3
igendreau wrote:
Hey Tim, what does the "d" do in your code?

I copied and pasted your string exactly, then substituded
[WO_REQUEST_DATE] for [BookingDate] which is my date field. I created
a new query based on my table, and posted this to create a new
calculated field. It immediately gives me an error saying I have
invalid syntax, and when I hit "Okay" it highlights the "d". Here's my
code:

Projected_Date: Switch(DateDiff("d",[BookingDate],Date())<=30,"0-30
Days Out",DateDiff("d",[BookingDate],Date())<=60,"31-60 Days
Out",DateDiff("d",[BookingDate],Date())<=90,"61 to 90
Days",DateDiff("d",[BookingDate],Date())>90,"Over 90 Days Out")

The "d" is the argument for the datediff function (not sure what version
of Access you're using but you can look this up in help). You say you
pasted it exactly, so, hopefully you haven't removed any qutation marks
that are in the switch expression.

Another thing to be aware of is to make sure any line breaks from
pasting the code are removed. I just copy and pasted from my news
reader your reply message and my first results only gave me "0-30"
instead of "0-30 Days Out". I got rid of the line breaks and everything
went tickity boo! 8)

An easy way of doing this is pasting the code in Word and removing line
breaks and then copying and pasting into the query design grid.

The other thing to be certain of - is BookingDate a date field? Stupid
question and I'm not trying to insult your intelligence, but it's easy
to overlook the easy things sometimes... 8)

Anther thing - did you paste this into the SQL view or the query design
grid? The expression is designed to be pasted into the design grid. If
you want to put it directly into SQL, then you'd place the following
after a comma in the select clause:

Switch(DateDiff("d",[BookingDate],Date())<=30,"0-30 Days
Out",DateDiff("d",[BookingDate],Date())<=60,"31-60 Days
Out",DateDiff("d",[BookingDate],Date())<=90,"61 to 90
Days",DateDiff("d",[BookingDate],Date())>90,"Over 90 Days Out") as
Projected_Date

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Feb 15 '06 #4
Worked like a charm. Thanks Tim!

Feb 17 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: amber | last post by:
Hello, I have a report in VB.NET/Crystal Reports. I have a criteria form that users select between 2 different types of grouping (group by category or group by year). Can I programmatically...
1
by: Brian Coy | last post by:
I am creating a database to track scrap on a daily basis at my plant. I have to provide a weekly scrap report with the amount of each part scrapped per day. I have the basic database set up, and...
3
by: Miguelito Bain | last post by:
hi- i have a simple table. i have 3 fields, id, indate, and outdate. i want to group these fields in my report by month. for example, for february 2004, i want to display all the ids and dates...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
8
by: Mike MacSween | last post by:
tblCourses one to many to tblEvents. A course may have an intro workshop (a type of event), a mid course workshop, a final exam. Or any combination. Or something different in the future. At...
1
by: Jon via AccessMonster.com | last post by:
Hi Guys, My "Sorting and Grouping" in my report looks like this: Field/Expression Sort Order sID Ascending ((= Project Name Ascending User *** ...
4
by: CH | last post by:
Hi, I recently encountered a problem while trying to create a report grouped by certain time frames. However, Access only allows grouping in Minutes or Hours. For example, the first time frame is...
6
by: craig.buchinski | last post by:
Ok, i have a Access Database (which is used with my ESRI Arcmap) and i have written a query for a report to pull out our streetlights and group them by billing wattage. The problem is that it is...
2
by: CoopEng | last post by:
Hey Team, Here's one for you all to ponder. In Access 2003, I'm updating a Operations Database for a manufacturing plant. The data is of production runs for the plant. So there are start date's...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.