LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 127
Default Using DSUM on a Recordset

Excel 2003. I have the following code that queries an SQL database and fills
up a recordset called "rs." Is there a way to then use the DSUM function on
the recordset? I get an error when I try using the DSUM. The connection
works fine and the recordset is filled without error.

Set cn = New ADODB.Connection
cn.Open "Provider=sqloledb;" & _
"Data Source=HQServer;" & _
"Initial Catalog=Good_News_FE;" & _
"User ID=FEOpen7;" & _
"Password=fe"
sql = "SELECT GL7PROJECTS.PROJECTID AS ProjectID, GL7PROJECTS.DESCRIPTION
AS [Project Description], GL7ACCOUNTS.ACCOUNTNUMBER AS Account,
GL7ACCOUNTS.DESCRIPTION AS [Account Description], GL7FISCALPERIODS.SEQUENCE
AS [Month], GL7PROJECTBUDGETDETAILS.AMOUNT AS [Month Amt],
GL7PROJECTBUDGETS.AMOUNT AS Total, GL7FISCALPERIODS.STARTDATE,
GL7FISCALPERIODS.ENDDATE " & _
"FROM ((((GL7PROJECTBUDGETS INNER JOIN GL7PROJECTBUDGETDETAILS ON
GL7PROJECTBUDGETS.GL7PROJECTBUDGETSID =
GL7PROJECTBUDGETDETAILS.GL7PROJECTBUDGETSID) INNER JOIN GL7ACCOUNTS ON
GL7PROJECTBUDGETS.GL7ACCOUNTSID = GL7ACCOUNTS.GL7ACCOUNTSID) INNER JOIN
GL7FISCALPERIODS ON (GL7PROJECTBUDGETDETAILS.GL7FISCALPERIODSID =
GL7FISCALPERIODS.GL7FISCALPERIODSID) AND
(GL7PROJECTBUDGETDETAILS.GL7FISCALPERIODSID =
GL7FISCALPERIODS.GL7FISCALPERIODSID)) INNER JOIN GL7PROJECTS ON
GL7PROJECTBUDGETS.GL7PROJECTSID = GL7PROJECTS.GL7PROJECTSID) " & _
"INNER JOIN GL7FISCALYEARS ON GL7FISCALPERIODS.GL7FISCALYEARSID =
GL7FISCALYEARS.GL7FISCALYEARSID " & _
"WHERE (((GL7FISCALPERIODS.STARTDATE)='1/1/2006') AND
((GL7FISCALPERIODS.ENDDATE)<='12/31/2006')) " & _
"ORDER BY GL7PROJECTS.PROJECTID, GL7ACCOUNTS.ACCOUNTNUMBER,
GL7FISCALPERIODS.SEQUENCE;"

Set rs = cn.Execute(sql, , adCmdText)

*THIS IS WHAT DOES NOT WORK

IFL = DSum("[Month Amt]", rs, "[Account]='1-4100'")

--
Dr. Doug Pruiett
Good News Jail & Prison Ministry
www.goodnewsjail.org
 
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
Copy From Recordset Nath Excel Programming 0 July 13th 04 12:30 PM
Type recordset/recordset? FlaviusFlav[_9_] Excel Programming 4 May 24th 04 12:16 PM
Recordset Stephan Kassanke Excel Programming 0 September 10th 03 04:45 PM
Looping Through A Recordset Tim Williams Excel Programming 0 August 20th 03 05:52 AM
Looping Through A Recordset Bob Phillips[_5_] Excel Programming 0 August 19th 03 03:34 PM


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

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

About Us

"It's about Microsoft Excel"