Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Sum MSAccess field quantities in a recordset from MSExcel

What other info do you need? I would do it in Access if I knew how.
But I need to sum all the data in that field and then put that one
total number in a cell in Excel.


....this is just a snipet from my coding...

sMCode = "M"
str = "SELECT SUM(maint_time) AS TOTAL FROM AvgDays WHERE isitM = '" &
sMCode & "' AND curr_location < '" & cl & "' AND county < '" & cnty
& "' GROUP BY maint_time"
rs.Open str, cn, adOpenKeyset, adLockOptimistic
lRecords = rs.RecordCount
MsgBox lRecords

this just gets me a total number of records that match that criteria
(9). I want the total of all the numbers in those 9 records.

?????

Mike wrote:
A little more info may help. Why dont you just make the query in Access?

"gab1972" wrote:

Sorry if the subject sounded confusing. Here's what I'm trying to
accomplish.

I have an Access database named AvgDays. In that recordset, I have
the following columns:
permit_num
county
isitD
isitM
dist_days
maint_days
curr_location

dist_days and main_days have a number of days. isitM could contain a
letter, "M". This means that not all of the records have an M in the
field.

What I want to accomplish:
Search every record in the recordset AvgDays where isitM = "M"...when
found, I want to continuously sum maint_days...so that it searches all
records and sums the total number of days. So if there are 100
records and say 75 have the letter M in isitM, I want to sum that
value, move to the next record, add that number, and so and so forth.

Is this possible? Any help would be GREATLY appreciated.
.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Sum MSAccess field quantities in a recordset from MSExcel

something like this im guessing
With rs
Do While (Not .EOF)
Range("A2").Value = Range("A2").Value +
..Fields("TOTAL").Value
.MoveNext
Loop
End With

"gab1972" wrote:

What other info do you need? I would do it in Access if I knew how.
But I need to sum all the data in that field and then put that one
total number in a cell in Excel.


....this is just a snipet from my coding...

sMCode = "M"
str = "SELECT SUM(maint_time) AS TOTAL FROM AvgDays WHERE isitM = '" &
sMCode & "' AND curr_location < '" & cl & "' AND county < '" & cnty
& "' GROUP BY maint_time"
rs.Open str, cn, adOpenKeyset, adLockOptimistic
lRecords = rs.RecordCount
MsgBox lRecords

this just gets me a total number of records that match that criteria
(9). I want the total of all the numbers in those 9 records.

?????

Mike wrote:
A little more info may help. Why dont you just make the query in Access?

"gab1972" wrote:

Sorry if the subject sounded confusing. Here's what I'm trying to
accomplish.

I have an Access database named AvgDays. In that recordset, I have
the following columns:
permit_num
county
isitD
isitM
dist_days
maint_days
curr_location

dist_days and main_days have a number of days. isitM could contain a
letter, "M". This means that not all of the records have an M in the
field.

What I want to accomplish:
Search every record in the recordset AvgDays where isitM = "M"...when
found, I want to continuously sum maint_days...so that it searches all
records and sums the total number of days. So if there are 100
records and say 75 have the letter M in isitM, I want to sum that
value, move to the next record, add that number, and so and so forth.

Is this possible? Any help would be GREATLY appreciated.
.

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default Sum MSAccess field quantities in a recordset from MSExcel

Thanks! That's exactly what I was looking for!!

Mike wrote:
something like this im guessing
With rs
Do While (Not .EOF)
Range("A2").Value = Range("A2").Value +
.Fields("TOTAL").Value
.MoveNext
Loop
End With

"gab1972" wrote:

What other info do you need? I would do it in Access if I knew how.
But I need to sum all the data in that field and then put that one
total number in a cell in Excel.


....this is just a snipet from my coding...

sMCode = "M"
str = "SELECT SUM(maint_time) AS TOTAL FROM AvgDays WHERE isitM = '" &
sMCode & "' AND curr_location < '" & cl & "' AND county < '" & cnty
& "' GROUP BY maint_time"
rs.Open str, cn, adOpenKeyset, adLockOptimistic
lRecords = rs.RecordCount
MsgBox lRecords

this just gets me a total number of records that match that criteria
(9). I want the total of all the numbers in those 9 records.

?????

Mike wrote:
A little more info may help. Why dont you just make the query in Access?

"gab1972" wrote:

Sorry if the subject sounded confusing. Here's what I'm trying to
accomplish.

I have an Access database named AvgDays. In that recordset, I have
the following columns:
permit_num
county
isitD
isitM
dist_days
maint_days
curr_location

dist_days and main_days have a number of days. isitM could contain a
letter, "M". This means that not all of the records have an M in the
field.

What I want to accomplish:
Search every record in the recordset AvgDays where isitM = "M"...when
found, I want to continuously sum maint_days...so that it searches all
records and sums the total number of days. So if there are 100
records and say 75 have the letter M in isitM, I want to sum that
value, move to the next record, add that number, and so and so forth.

Is this possible? Any help would be GREATLY appreciated.
.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing twice a memo field in a recordset majorri Excel Programming 4 January 16th 09 02:28 PM
ADO Recordset include Field names Kirk P. Excel Programming 2 April 18th 07 09:08 PM
Summarizing field quantities for specific records Charleswdowd Excel Worksheet Functions 0 June 2nd 06 01:12 AM
ADO cloned recordset doesn't return field names quartz[_2_] Excel Programming 3 March 16th 05 09:49 PM
DAO query/recordset returns with field names Seth[_4_] Excel Programming 0 August 18th 03 08:36 PM


All times are GMT +1. The time now is 11:36 AM.

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

About Us

"It's about Microsoft Excel"