473,623 Members | 2,433 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Crosstab Query using date ranges

62 New Member
I am trying to get a crosstab query (in access 2000) to group data by date range.

Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Sum(tblInvoice.InvBalance) AS SumOfInvBalance
  2. SELECT tblInvoice.DealerID, Sum(tblInvoice.InvBalance) AS [Total Of InvBalance]
  3. FROM tblInvoice
  4. GROUP BY tblInvoice.DealerID
  5. PIVOT Format(Now(),"ww");
I know the above code is wrong! My question is how do I get the query to group outstanding Invoice Balances (InvBalance) into the following date ranges (InvDate):
0 - 29 days, 30 - 59 days, 60 - 89 days, 90+ days

I am trying to develop a Debtors List by Dealer (DealerID) eg.

0 - 29 days 30 - 59 days 60 - 89 days 90+ days
Dealer1 £50 £250
Dealer2 £234 £453 £5
Dealer3 £23 £68 £1000


Hope this makes sense
Apr 25 '07 #1
22 5003
NeoPa
32,566 Recognized Expert Moderator MVP
I'm no good with CrossTabs at all, but couldn't you make up a field in your source (or underlying) query that uses the Switch() function to return the groupings that you want :
Expand|Select|Wrap|Line Numbers
  1. Switch([InvDate]-Date()<30,"A",[InvDate]-Date()<60,"B",[InvDate]-Date()<90,"C",TRUE,"D")
Grouping by the result of this should do what you want.
Apr 26 '07 #2
boliches
62 New Member
I'm no good with CrossTabs at all, but couldn't you make up a field in your source (or underlying) query that uses the Switch() function to return the groupings that you want :
Expand|Select|Wrap|Line Numbers
  1. Switch([InvDate]-Date()<30,"A",[InvDate]-Date()<60,"B",[InvDate]-Date()<90,"C",TRUE,"D")
Grouping by the result of this should do what you want.

Hi
Will this work in MS Access 2000?
Apr 27 '07 #3
NeoPa
32,566 Recognized Expert Moderator MVP
You still need to incorporate it into your CrossTab query properly, but the function call itself should work in Access 2K, yes.
Apr 27 '07 #4
boliches
62 New Member
You still need to incorporate it into your CrossTab query properly, but the function call itself should work in Access 2K, yes.

BAFFLED!!

Have tried the following, plus variations of, to no avail!

TRANSFORM Sum(tblInvoice. InvBalance) AS SumOfInvBalance
SELECT tblInvoice.Deal erID, Count(tblInvoic e.DealNo) AS CountOfDealNo, Sum(tblInvoice. InvBalance) AS [Total Of InvBalance]
FROM tblInvoice
GROUP BY tblInvoice.Deal erID
PIVOT Switch([InvDate] Between Now() And Now()=30,"0-30 Days",[InvDate] Between Date()+30 And Date()+60,"30 - 60 Days",[InvDate] Between Date()+60 And Date()+90,"60 - 90 Days",[InvDate]-Date()+90,"90+ Days");

Any ideas?

Thanks
Apr 27 '07 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Sum(tblInvoice.InvBalance) AS SumOfInvBalance
  2. SELECT tblInvoice.DealerID, Count(tblInvoice.DealNo) AS CountOfDealNo, Sum(tblInvoice.InvBalance) AS [Total Of InvBalance]
  3. FROM tblInvoice
  4. GROUP BY tblInvoice.DealerID
  5. PIVOT  IIf([InvDate] Between Now() And Now()+30,"0-30 Days",
  6. IIf([InvDate] Between Date()+30 And Date()+60,"30 - 60 Days",IIf([InvDate] Between Date()+60 And Date()+90,"60 - 90 Days","90+ Days")));
  7.  
Mary
Apr 28 '07 #6
boliches
62 New Member
Try this ...
Expand|Select|Wrap|Line Numbers
  1. TRANSFORM Sum(tblInvoice.InvBalance) AS SumOfInvBalance
  2. SELECT tblInvoice.DealerID, Count(tblInvoice.DealNo) AS CountOfDealNo, Sum(tblInvoice.InvBalance) AS [Total Of InvBalance]
  3. FROM tblInvoice
  4. GROUP BY tblInvoice.DealerID
  5. PIVOT  IIf([InvDate] Between Now() And Now()+30,"0-30 Days",
  6. IIf([InvDate] Between Date()+30 And Date()+60,"30 - 60 Days",IIf([InvDate] Between Date()+60 And Date()+90,"60 - 90 Days","90+ Days")));
  7.  
Mary
Hi Mary
I think we are somewhere close, but at this moment all records are being placed in 90+ days whereas some records are within 30 - 60 days range etc.

I am trying to create a list of customers outstanding invoices by date range ( a "Debtors List") so that I know which are the oldest ane therefore need 'chasing' for payment. Am I going in the right direction with a Crosstab Query? Or is there a simpler solution?

Thanks.
Apr 29 '07 #7
boliches
62 New Member
Hi Mary
I think we are somewhere close, but at this moment all records are being placed in 90+ days whereas some records are within 30 - 60 days range etc.

I am trying to create a list of customers outstanding invoices by date range ( a "Debtors List") so that I know which are the oldest ane therefore need 'chasing' for payment. Am I going in the right direction with a Crosstab Query? Or is there a simpler solution?

Thanks.
Hi Mary

SOLVED IT!!!

Thank you so much for your help (and "NeoPa")

I changed the "+" to a "-" (Iif Now()-30 And Now()-60 ) and HAPPY DAYS! it works.

You guys are Brilliant!

Bruce
Apr 29 '07 #8
boliches
62 New Member
Next problem:

I would like to filter the data by "Broker", but get a message:
The Microsoft Jet Database Engine does not recognize "Forms!frmMainF orm.Text265" as a valid field name or expression.

The field Text265 is on a form (frmMainForm) and holds the logged on "Brokers" initials. I have entered this as the criteria in the query but it gives the above massage when run.

I have tried : "Like", "=" but still get the message, any ideas as to how I filter the data to a given Brokers Initials?

Thanks
Apr 29 '07 #9
MMcCarthy
14,534 Recognized Expert Moderator MVP
Next problem:

I would like to filter the data by "Broker", but get a message:
The Microsoft Jet Database Engine does not recognize "Forms!frmMainF orm.Text265" as a valid field name or expression.

The field Text265 is on a form (frmMainForm) and holds the logged on "Brokers" initials. I have entered this as the criteria in the query but it gives the above massage when run.

I have tried : "Like", "=" but still get the message, any ideas as to how I filter the data to a given Brokers Initials?

Thanks
Open the properties for Text265 in form design view. Under the other tab check the Name property. Is it Text265?
Apr 29 '07 #10

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

Similar topics

8
7562
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 want them to do as little as possible when they run their reports. I have a crosstab query that displays usage of items for each month. It looks pretty much like this: ITEM DESC UM 12/02 1/03 2/03 3/03 ...ETC. 1 Solution ...
1
17656
by: Nathan Bloomfield | last post by:
Does anyone know if there is any documentation which relates to Access2k + ? or can anyone help adjust the code? I am having trouble converting the DAO references. TITLE :INF: How to Create a Dynamic Crosstab Report PRODUCT :Microsoft Access PROD/VER:1.00 1.10 OPER/SYS:WINDOWS
2
3037
by: Sherman H. | last post by:
I have a few questions for crosstab and popup form questions: 1. I created a crosstab as follows: IT Financial Operation John 21 22 22 Mary 15 17 16 Joe 28 29 31 For some other instances, the Operation column was not created because the
2
2247
by: carl.barrett | last post by:
Hi, I'm back with the same question as I still can't get it to display my data the way I want it to. The table lists information about a perpetrator involved with an anti social behaviour order. The table contains personal information about the individual as well as (here is where the letter dates comes in:) e.g.
2
5954
by: Claus Haslauer | last post by:
Hi, I want to create a crosstab query that looks like this Date | Elevation 1 | Elevation 2 | ... ______________________________________________________________________ Date 1 | xx.y | xx.y Date 2 | xx.y | xx.y xx.y are measurements taken at different dates at different elevations. xx.y and elevation happen to be in the same format (meters).
2
2930
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic sub-report will capture what grades the student has achieved in a list of different subjects and the reason I need it to be dynamic is that students take different subjects. Basically I've been trying to doctor the KB article on dynamic
14
3482
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity. However, the expectation changes - it may be 60% for a while, then change to 50%. Initially, I was averaging the expectation, along with the productivity, but what I'm being asked is to look at the average productivity/performance compared to...
4
6468
by: m.wanstall | last post by:
I have a crosstab query that compiles data for Months of the year. I have a stacked select query on top of that crosstab query that uses the latest 2 months data and exports it to a fixed length flat file. Ideally I would like to be able to just select the Last 2 Columns of the Crosstab query as inputs to the Select query WITHOUT having to go in month after month and manually change it... I may be asking a bit much here but is there a...
2
3396
by: Jim Devenish | last post by:
I wish to create a crosstab query as the record source for a report. It needs to count data between selected dates which are entered by the user in a popup window. The following Select query works: SELECT Tasks.EnquirySourceID, Tasks.BusinessUnitID, Count(Tasks.TaskID) AS CountOfTaskID FROM Tasks WHERE (((Tasks.TaskDate)>=!!)) GROUP BY Tasks.EnquirySourceID, Tasks.BusinessUnitID;
0
8165
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8326
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8469
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4074
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1778
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1473
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.