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: 33
Default ADODB Question

Greetings! I am new to ADODB area. If I used the SQL statement with MAX
below, the strResult = oRS("DATE_COMPLETED") gives me an error saying "Run
Time Error 3625: Item can't be found in the collection corresponding to the
requested name or ordinal"

sSQL = "SELECT MAX(DATE_COMPLETED) FROM PATRNHIST WHERE EMPLOYEE=7031 AND
(COURSE='PROC-PRP' Or COURSE='PROC-PEREV' Or COURSE='PROC-PRFI')"

BUT, if I removed MAX, it worked fine with following code. I do need MAX,
how should I fix it. Thanks.



Sub try()

Dim oConn As Object
Dim oRS As Object
Dim sSQL As String
Dim myArray
Dim i As Integer
Dim strResult As String

i = 0

Set oConn = CreateObject("ADODB.Connection")
oConn.Open "DSN=sralaw;UID=pmguser;PWD=pmgprod"

Set oRS = CreateObject("ADODB.Recordset")
sSQL = "SELECT DATE_COMPLETED FROM PATRNHIST WHERE EMPLOYEE=7031 AND
(COURSE='PROC-PRP' Or COURSE='PROC-PEREV' Or COURSE='PROC-PRFI')"
oRS.Open sSQL, oConn
Do While (Not (oRS.EOF))
strResult = oRS("DATE_COMPLETED")
Worksheets("Sheet1").Range("A" & i + 1).Value = strResult
i = i + 1
oRS.MoveNext
Loop

oRS.Close
Set oRS = Nothing
oConn.Close
Set oConn = Nothing

End Sub




 
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
ADODB Connection fi.or.jp.de Excel Worksheet Functions 0 September 9th 09 09:23 PM
Problems with ADODB Eric Wescott Excel Programming 6 October 20th 04 03:50 PM
0 with ADODB Recordset Stefen Percoco Excel Programming 1 July 8th 04 09:54 PM
ADODB Richard Mogy Excel Programming 3 May 6th 04 09:14 PM
ADODB Recordset Seth[_3_] Excel Programming 0 August 5th 03 02:15 PM


All times are GMT +1. The time now is 09:02 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"