A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Year-To-Date Query Help Needed



 
 
Thread Tools Display Modes
  #1  
Old February 7th, 2008, 05:23 PM posted to microsoft.public.access.queries
Terry
external usenet poster
 
Posts: 15
Default Year-To-Date Query Help Needed

I don't know if this is a query question or a report question or both, but
I'm really confused.

I have a table (tblGL) with the following fields in it:
dtmDate = Date Field
strAccountId = Text Field
curDebit = Currency Field
curCredit = Currency Field

What I am trying to accomplish is to run a query in orfer to produce a
report that will print out the following information:

Account ID Current Month Y-T-D
1000 $100.00 $300.00
2000 0 $500.00

In other words, I want to pull a query to be used in a report to show three
columns. First column Account Number, Second Column, Current Month's Total
for this account, and third column the year to date amount for this account.

Any suggestions on how to accomplish this would be greatly appreciated.

Thanks,
Terry


  #2  
Old February 7th, 2008, 07:14 PM posted to microsoft.public.access.queries
Klatuu
external usenet poster
 
Posts: 7,074
Default Year-To-Date Query Help Needed

SELECT dtmDate, strAccountId, curDebit, curCredit FROM tblGL WHERE
Year(dtmDate) = Year(Date()) AND dtmDate = Date();

Will return only records for the current year that are up to and including
today's date.
--
Dave Hargis, Microsoft Access MVP


"Terry" wrote:

I don't know if this is a query question or a report question or both, but
I'm really confused.

I have a table (tblGL) with the following fields in it:
dtmDate = Date Field
strAccountId = Text Field
curDebit = Currency Field
curCredit = Currency Field

What I am trying to accomplish is to run a query in orfer to produce a
report that will print out the following information:

Account ID Current Month Y-T-D
1000 $100.00 $300.00
2000 0 $500.00

In other words, I want to pull a query to be used in a report to show three
columns. First column Account Number, Second Column, Current Month's Total
for this account, and third column the year to date amount for this account.

Any suggestions on how to accomplish this would be greatly appreciated.

Thanks,
Terry



  #3  
Old February 7th, 2008, 07:44 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Year-To-Date Query Help Needed

PERHAPS

SELECT strAccountID
, Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curCred it,0) -
Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curDebi t,0) as CurMonth
, Sum(curCredit) - Sum(curDebit) as YTD
FROM tblGL
WHERE Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0)
GROUP BY strAccountID

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"Terry" wrote in message
...
I don't know if this is a query question or a report question or both, but
I'm really confused.

I have a table (tblGL) with the following fields in it:
dtmDate = Date Field
strAccountId = Text Field
curDebit = Currency Field
curCredit = Currency Field

What I am trying to accomplish is to run a query in orfer to produce a
report that will print out the following information:

Account ID Current Month Y-T-D
1000 $100.00 $300.00
2000 0 $500.00

In other words, I want to pull a query to be used in a report to show
three columns. First column Account Number, Second Column, Current
Month's Total for this account, and third column the year to date amount
for this account.

Any suggestions on how to accomplish this would be greatly appreciated.

Thanks,
Terry




  #4  
Old February 7th, 2008, 08:03 PM posted to microsoft.public.access.queries
Terry
external usenet poster
 
Posts: 15
Default Year-To-Date Query Help Needed

I tried this, but I get a Syntax error that there is a missing operator in
query expression.


"John Spencer" wrote in message
...
PERHAPS

SELECT strAccountID
, Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curCred it,0) -
Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curDebi t,0) as CurMonth
, Sum(curCredit) - Sum(curDebit) as YTD
FROM tblGL
WHERE Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0)
GROUP BY strAccountID

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"Terry" wrote in message
...
I don't know if this is a query question or a report question or both, but
I'm really confused.

I have a table (tblGL) with the following fields in it:
dtmDate = Date Field
strAccountId = Text Field
curDebit = Currency Field
curCredit = Currency Field

What I am trying to accomplish is to run a query in orfer to produce a
report that will print out the following information:

Account ID Current Month Y-T-D
1000 $100.00 $300.00
2000 0 $500.00

In other words, I want to pull a query to be used in a report to show
three columns. First column Account Number, Second Column, Current
Month's Total for this account, and third column the year to date amount
for this account.

Any suggestions on how to accomplish this would be greatly appreciated.

Thanks,
Terry







  #5  
Old February 7th, 2008, 08:24 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Year-To-Date Query Help Needed

Well I did miss something in the where clause - what field should be in the
comparison.

I may have missed a parentheses or two also - although (obviously) I don't
see that I am.

SELECT strAccountID
, Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curCred it,0) -
Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curDebi t,0) as CurMonth
, Sum(curCredit) - Sum(curDebit) as YTD
FROM tblGL
WHERE dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0)
GROUP BY strAccountID

Try this one. If it fails try removing items form the select clause to see
if one of them is faulty.
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
..

"John Spencer" wrote in message
...
PERHAPS

SELECT strAccountID
, Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curCred it,0) -
Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curDebi t,0) as CurMonth
, Sum(curCredit) - Sum(curDebit) as YTD
FROM tblGL
WHERE Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0)
GROUP BY strAccountID

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"Terry" wrote in message
...
I don't know if this is a query question or a report question or both, but
I'm really confused.

I have a table (tblGL) with the following fields in it:
dtmDate = Date Field
strAccountId = Text Field
curDebit = Currency Field
curCredit = Currency Field

What I am trying to accomplish is to run a query in orfer to produce a
report that will print out the following information:

Account ID Current Month Y-T-D
1000 $100.00 $300.00
2000 0 $500.00

In other words, I want to pull a query to be used in a report to show
three columns. First column Account Number, Second Column, Current
Month's Total for this account, and third column the year to date amount
for this account.

Any suggestions on how to accomplish this would be greatly appreciated.

Thanks,
Terry






  #6  
Old February 11th, 2008, 03:19 PM posted to microsoft.public.access.queries
Terry
external usenet poster
 
Posts: 15
Default Year-To-Date Query Help Needed

John:

Thank you so much for trying to help me in this matter, but for the life of
me, I still can not get the query to work. Is there something else that I
might try.

Thanks,
Terry


"John Spencer" wrote in message
...
Well I did miss something in the where clause - what field should be in
the comparison.

I may have missed a parentheses or two also - although (obviously) I don't
see that I am.

SELECT strAccountID
, Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curCred it,0) -
Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curDebi t,0) as CurMonth
, Sum(curCredit) - Sum(curDebit) as YTD
FROM tblGL
WHERE dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0)
GROUP BY strAccountID

Try this one. If it fails try removing items form the select clause to
see if one of them is faulty.
--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"John Spencer" wrote in message
...
PERHAPS

SELECT strAccountID
, Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curCred it,0) -
Sum(IIF(dtmDate Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0),curDebi t,0) as CurMonth
, Sum(curCredit) - Sum(curDebit) as YTD
FROM tblGL
WHERE Between DateSerial(Year(Date()),Month(Date()),1) and
DateSerial(Year(Date()),Month(Date())+1,0)
GROUP BY strAccountID

--
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
.

"Terry" wrote in message
...
I don't know if this is a query question or a report question or both,
but I'm really confused.

I have a table (tblGL) with the following fields in it:
dtmDate = Date Field
strAccountId = Text Field
curDebit = Currency Field
curCredit = Currency Field

What I am trying to accomplish is to run a query in orfer to produce a
report that will print out the following information:

Account ID Current Month Y-T-D
1000 $100.00 $300.00
2000 0 $500.00

In other words, I want to pull a query to be used in a report to show
three columns. First column Account Number, Second Column, Current
Month's Total for this account, and third column the year to date amount
for this account.

Any suggestions on how to accomplish this would be greatly appreciated.

Thanks,
Terry









  #7  
Old February 11th, 2008, 11:35 PM posted to microsoft.public.access.queries
Michael Gramelspacher
external usenet poster
 
Posts: 482
Default Year-To-Date Query Help Needed

On Mon, 11 Feb 2008 09:19:16 -0600, "Terry" wrote:

Thank you so much for trying to help me in this matter, but for the life of
me, I still can not get the query to work. Is there something else that I
might try.

Thanks,
Terry


PARAMETERS [Enter Date:] DateTime;
SELECT strAccountID,
SUM(IIF(DATEDIFF("m",DATEADD("m",DATEDIFF("m",0,[Enter Date:]),0),
dtmDate) = 0,curCredit - curDebit,
0)) AS MTD,
SUM(IIF(DATEDIFF("yyyy",DATEADD("yyyy",DATEDIFF("y yyy",0,[Enter
Date:]),0),
dtmDate) = 0,curCredit - curDebit,
0)) AS YTD
FROM tblGL
WHERE dtmDate IS NOT NULL
AND dtmDate DATEADD("d",1,[Enter Date:])
GROUP BY strAccountID;
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:13 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.