Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
ADODB Connection | Excel Worksheet Functions | |||
Problems with ADODB | Excel Programming | |||
0 with ADODB Recordset | Excel Programming | |||
ADODB | Excel Programming | |||
ADODB Recordset | Excel Programming |