View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] luke.goodfellow@gmail.com is offline
external usenet poster
 
Posts: 1
Default Error during retrieval of ADODBrecordset

hi all,

a client is receiving the error:

Error 1004: Application-defined or object-defined error.

when inserting data into a worksheet from an adodb recordset. the
error occurs when trying to retreive the 7th field in the first row of
data (a string field with value "hour"). The previous fields are all
strings or dates.

example of code with additional comment on the line with the problem is
below.

thanks in advance,

L.


....
Dim rs As ADODB.Recordset
Dim f As ADODB.Field
Dim i As Integer
Dim j As Integer

... set query, retrieve query result into rs


' set headings
If Not rs.EOF Then
i = 0
For Each f In rs.Fields
shtAccrual.Range("A12").Offset(0, i).Value = f.Name
i = i + 1
Next
End If

' set values
j = 0
Do Until rs.EOF
i = 0
For Each f In rs.Fields
' error occurs here for j = 0, i = 6, f.value = "hour"
shtAccrual.Range("A13").Offset(currow, i).Value = f.Value
Next f
rs.MoveNext
j = j + 1
Loop
rs.Close
....