Link to home
Start Free TrialLog in
Avatar of PeterBaileyUk
PeterBaileyUk

asked on

get each row from recordset into excel worksheet

I have been using the vba command
wks.Range("A2").CopyFromRecordset qdf.OpenRecordset

to return the recordset but it appears to be missing some rows.

I have checked the parameters passed to the query and they are correct.

is there a way to get each row from the recordset one by one?

ie movefirst then get row then movenext and so on until the end of the recordset?

this way i can test better. I am in excel vba.

  For Each prm In qdf.Parameters
  Debug.Print prm.Name, prm.Value
Next
Set wks = Sheets("CWCodesToMatch")
Dim iCols As Long

For iCols = 0 To qdf.OpenRecordset.Fields.Count - 1
    wks.Cells(1, iCols + 1).Value = qdf.OpenRecordset.Fields(iCols).Name
Next
wks.Range(wks.Cells(1, 1), _
    wks.Cells(1, qdf.OpenRecordset.Fields.Count)).Font.Bold = True
wks.Range("A2").CopyFromRecordset qdf.OpenRecordset

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Member_2_861731
Member_2_861731
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial