View Full Version : Copyfromrecordsetobject failed 2147467259


Sreedevi
07-21-2008, 05:45 AM
Hi All,

I am going mad:confused: with this error, please help on this.

Some times I am getting Copyfromrecordset object failed and some times I am getting Automation error with the same error number 2147467259.

Here is my code:
Set rng = pwksRpt.Cells(lngNext, 1)
pdb.QueryDefs.Refresh

Set qdf = pdb.QueryDefs("qryActPlan_" & strQRY)
Set rs = qdf.OpenRecordset

If Not rs.EOF Then
rs.MoveLast

If InStr(1, strQRY, "Attrib") > 0 Then
lngRows = Application.Max(rs.RecordCount, cintRowsAttrib)
Else
lngRows = rs.RecordCount
End If
rs.MoveFirst

rngFormat.Copy rng.Resize(lngRows, rngFormat.Columns.Count)
Application.CutCopyMode = False

rng.CopyFromRecordset rs (in this line I am getting the error)
rs.Close

lngNext = lngNext + lngRows

Else

If InStr(1, strQRY, "Attrib") > 0 Then
lngRows = cintRowsAttrib

rngFormat.Copy rng.Resize (lngRows, rngFormat.Columns.Count)
Application.CutCopyMode = False

lngNext = lngNext + lngRows
End If
End If

Set rs = Nothing
Set qdf = Nothing
rng.ClearContents
Set rng = Nothing

Next i

Any help would be great!!!!!!!!!!!

Thanks in advance.

chergh
07-21-2008, 05:54 AM
In the queries you are using to generate your recordset are there any memo fields on embedded object fields being selected?

Sreedevi
07-21-2008, 09:59 PM
Thanks for the help!!!!!!

But the problem is, it is pasting some of the rows and after that it shows the error.

Query is resulting into 166 records, it is pasting 97 records on the sheet and after that it is failing, I checked the values for the next rows they are same as the above rows.

I tried including TOP 100 in the query, then it pastes all the 100 records with out any error, I tried with TOP 110, then also it works fine, when I tried with TOP 115 again it failed. :mad:

I think some buffer issue but not sure.