Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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
....

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 253
Default Error during retrieval of ADODBrecordset

Hi Luke,
Few points/ideas :
Did you test if the value was null ? if ISNuill(f.value)
Tried to format : shtAccrual.Range("A12").Offset(0, i).Value = format
(f.Name,"hh:mm")
Use copyfromRecordset (and thus avoid to loop) :
shtAccrual.Range("A12").copyfromfrecordset rs
ps : don't communicate your correct email addressed if you don't want to get
spam
eg lukeDOTgoodfellowATgmail.com

Regards
JY

wrote in message
ups.com...
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
...



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
FTP information retrieval wintermute Excel Worksheet Functions 1 June 13th 08 10:10 AM
File Retrieval Gulf South Excel Discussion (Misc queries) 6 May 7th 08 08:24 PM
Row retrieval HELP!!! keinspahr Excel Discussion (Misc queries) 4 November 12th 07 02:40 PM
Data Retrieval pkpocket Excel Discussion (Misc queries) 2 October 2nd 07 12:50 AM
MAC Retrieval sparx Excel Discussion (Misc queries) 0 March 19th 06 08:51 PM


All times are GMT +1. The time now is 04:14 PM.

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"