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  

My running sum didn't work either



 
 
Thread Tools Display Modes
  #1  
Old June 20th, 2007, 03:38 PM posted to microsoft.public.access.queries
8020
external usenet poster
 
Posts: 10
Default My running sum didn't work either

I've read all the posts regarding similar problems and consulted the ms
support /kb/208714; all very informative. However, I still can't get it to
work! Any help appreciated. I have a table with fields Index, ItemNumber
and CumQtyCalc. I want to add a field to calculate a running sum by item in
a query based on this table. I can get a running sum for all items by using:

RunningTotalA: DSum("CumQtyCalc","tblTempTable","[Index] = " & [Index] & "")

However, when I try to do by item using the following, it doesn't work:

RunningTotalB: DSum("CumQtyCalc","tblTempTable","[Index] & [ItemNumber] =
'" & [Index] & [ItemNumber] & "'")

Could anyone point out my mistake? Thanks in advance.





  #2  
Old June 20th, 2007, 04:11 PM posted to microsoft.public.access.queries
Sasquatch
external usenet poster
 
Posts: 16
Default My running sum didn't work either

8020 wrote:
"I want to add a field to calculate a running sum by item in a query based
on this table"

Couldn't you use a "GroupBy" query to group the records by Index and
ItemNumber and then Sum the CumQtyCalc field?

For instance:
SELECT [Index], [ItemNumber], Sum([CumQtyCalc]) AS SumOfCumQtyCalc
FROM [tblTempTable]
GROUP BY [Index], [ItemNumber];


Hope that helps
  #3  
Old June 20th, 2007, 04:33 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default My running sum didn't work either

8020 wrote:

I've read all the posts regarding similar problems and consulted the ms
support /kb/208714; all very informative. However, I still can't get it to
work! Any help appreciated. I have a table with fields Index, ItemNumber
and CumQtyCalc. I want to add a field to calculate a running sum by item in
a query based on this table. I can get a running sum for all items by using:

RunningTotalA: DSum("CumQtyCalc","tblTempTable","[Index] = " & [Index] & "")

However, when I try to do by item using the following, it doesn't work:

RunningTotalB: DSum("CumQtyCalc","tblTempTable","[Index] & [ItemNumber] =
'" & [Index] & [ItemNumber] & "'")



Try using:

RunningTotalB: DSum("CumQtyCalc","tblTempTable",
"Index = '" & Index & "' And ItemNumber = " & ItemNumber)


Note that the quoting in the above assumes that Index is a
Text field and that ItemNumber is a number type field. If
that's not the case, adjust the quotes accordingly.

--
Marsh
MVP [MS Access]
  #4  
Old June 21st, 2007, 01:19 PM posted to microsoft.public.access.queries
8020
external usenet poster
 
Posts: 10
Default My running sum didn't work either

Cheers,

I tried some more but, I'm still having trouble (probably with the quotes?).
I'd appreciate any further assistance. To be more specific, the Index field
is an autonumber; this keeps the records in a specific order and ensures they
are unique, the ItemNumber field is text. The ItemNumber repeats but, always
occurs grouped together due to the Index field. The integers in the
CumQtyCalc are +ve and -ve and I want to have the running sum calculate (for
each record of) each ItemNumber group.

Thanks in advance,



"Marshall Barton" wrote:

8020 wrote:

I've read all the posts regarding similar problems and consulted the ms
support /kb/208714; all very informative. However, I still can't get it to
work! Any help appreciated. I have a table with fields Index, ItemNumber
and CumQtyCalc. I want to add a field to calculate a running sum by item in
a query based on this table. I can get a running sum for all items by using:

RunningTotalA: DSum("CumQtyCalc","tblTempTable","[Index] = " & [Index] & "")

However, when I try to do by item using the following, it doesn't work:

RunningTotalB: DSum("CumQtyCalc","tblTempTable","[Index] & [ItemNumber] =
'" & [Index] & [ItemNumber] & "'")



Try using:

RunningTotalB: DSum("CumQtyCalc","tblTempTable",
"Index = '" & Index & "' And ItemNumber = " & ItemNumber)


Note that the quoting in the above assumes that Index is a
Text field and that ItemNumber is a number type field. If
that's not the case, adjust the quotes accordingly.

--
Marsh
MVP [MS Access]

  #5  
Old June 21st, 2007, 06:16 PM posted to microsoft.public.access.queries
Marshall Barton
external usenet poster
 
Posts: 5,361
Default My running sum didn't work either

It appears that my guess about the field types was
backwards.

RunningTotalB: DSum("CumQtyCalc","tblTempTable",
"Index = " & Index & " And ItemNumber = '" & ItemNumber &
"' ")
--
Marsh
MVP [MS Access]


8020 wrote:
I tried some more but, I'm still having trouble (probably with the quotes?).
I'd appreciate any further assistance. To be more specific, the Index field
is an autonumber; this keeps the records in a specific order and ensures they
are unique, the ItemNumber field is text. The ItemNumber repeats but, always
occurs grouped together due to the Index field. The integers in the
CumQtyCalc are +ve and -ve and I want to have the running sum calculate (for
each record of) each ItemNumber group.


"Marshall Barton" wrote:

8020 wrote:

I've read all the posts regarding similar problems and consulted the ms
support /kb/208714; all very informative. However, I still can't get it to
work! Any help appreciated. I have a table with fields Index, ItemNumber
and CumQtyCalc. I want to add a field to calculate a running sum by item in
a query based on this table. I can get a running sum for all items by using:

RunningTotalA: DSum("CumQtyCalc","tblTempTable","[Index] = " & [Index] & "")

However, when I try to do by item using the following, it doesn't work:

RunningTotalB: DSum("CumQtyCalc","tblTempTable","[Index] & [ItemNumber] =
'" & [Index] & [ItemNumber] & "'")



Try using:

RunningTotalB: DSum("CumQtyCalc","tblTempTable",
"Index = '" & Index & "' And ItemNumber = " & ItemNumber)


Note that the quoting in the above assumes that Index is a
Text field and that ItemNumber is a number type field. If
that's not the case, adjust the quotes accordingly.

  #6  
Old June 22nd, 2007, 11:37 AM posted to microsoft.public.access.queries
8020
external usenet poster
 
Posts: 10
Default My running sum didn't work either

Works perfectly. Your input has been much appreciated. Thanks Marsh.


"Marshall Barton" wrote:

It appears that my guess about the field types was
backwards.

RunningTotalB: DSum("CumQtyCalc","tblTempTable",
"Index = " & Index & " And ItemNumber = '" & ItemNumber &
"' ")
--
Marsh
MVP [MS Access]


8020 wrote:
I tried some more but, I'm still having trouble (probably with the quotes?).
I'd appreciate any further assistance. To be more specific, the Index field
is an autonumber; this keeps the records in a specific order and ensures they
are unique, the ItemNumber field is text. The ItemNumber repeats but, always
occurs grouped together due to the Index field. The integers in the
CumQtyCalc are +ve and -ve and I want to have the running sum calculate (for
each record of) each ItemNumber group.


"Marshall Barton" wrote:

8020 wrote:

I've read all the posts regarding similar problems and consulted the ms
support /kb/208714; all very informative. However, I still can't get it to
work! Any help appreciated. I have a table with fields Index, ItemNumber
and CumQtyCalc. I want to add a field to calculate a running sum by item in
a query based on this table. I can get a running sum for all items by using:

RunningTotalA: DSum("CumQtyCalc","tblTempTable","[Index] = " & [Index] & "")

However, when I try to do by item using the following, it doesn't work:

RunningTotalB: DSum("CumQtyCalc","tblTempTable","[Index] & [ItemNumber] =
'" & [Index] & [ItemNumber] & "'")


Try using:

RunningTotalB: DSum("CumQtyCalc","tblTempTable",
"Index = '" & Index & "' And ItemNumber = " & ItemNumber)


Note that the quoting in the above assumes that Index is a
Text field and that ItemNumber is a number type field. If
that's not the case, adjust the quotes accordingly.


 




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 11:25 PM.


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