Hi All,
I am going mad 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.
I am going mad 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.