ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using ADO to get the first 5 fields horizontaly (https://www.excelbanter.com/excel-programming/421431-using-ado-get-first-5-fields-horizontaly.html)

dan

Using ADO to get the first 5 fields horizontaly
 
Hi,
I know how to retieve data via ADO from access.
But can I
1) retrieve only the first 5 first records of the result of SQL
2) display them in Excel horizontaly (First in A1, second in B1, third in
B3...)
Many thanks,
Dan

Mike

Using ADO to get the first 5 fields horizontaly
 
Try this
If (Not rs.BOF Or rs.EOF) Then
For i = 1 To 5
Cells(1, i) = rs.Fields("FieldName").Value
rs.MoveNext
Next i
End If

"Dan" wrote:

Hi,
I know how to retieve data via ADO from access.
But can I
1) retrieve only the first 5 first records of the result of SQL
2) display them in Excel horizontaly (First in A1, second in B1, third in
B3...)
Many thanks,
Dan


dan

Using ADO to get the first 5 fields horizontaly
 
Not working for me yet , do you maybe have the full code.
Many thanks,
Dan

"Mike" wrote:

Try this
If (Not rs.BOF Or rs.EOF) Then
For i = 1 To 5
Cells(1, i) = rs.Fields("FieldName").Value
rs.MoveNext
Next i
End If

"Dan" wrote:

Hi,
I know how to retieve data via ADO from access.
But can I
1) retrieve only the first 5 first records of the result of SQL
2) display them in Excel horizontaly (First in A1, second in B1, third in
B3...)
Many thanks,
Dan


dan

Using ADO to get the first 5 fields horizontaly
 
Sorry, working now, was my Typo, many thanks.
DAN

"Dan" wrote:

Hi,
I know how to retieve data via ADO from access.
But can I
1) retrieve only the first 5 first records of the result of SQL
2) display them in Excel horizontaly (First in A1, second in B1, third in
B3...)
Many thanks,
Dan


Mike

Using ADO to get the first 5 fields horizontaly
 
it would be better if you posted your code....

"Dan" wrote:

Not working for me yet , do you maybe have the full code.
Many thanks,
Dan

"Mike" wrote:

Try this
If (Not rs.BOF Or rs.EOF) Then
For i = 1 To 5
Cells(1, i) = rs.Fields("FieldName").Value
rs.MoveNext
Next i
End If

"Dan" wrote:

Hi,
I know how to retieve data via ADO from access.
But can I
1) retrieve only the first 5 first records of the result of SQL
2) display them in Excel horizontaly (First in A1, second in B1, third in
B3...)
Many thanks,
Dan



All times are GMT +1. The time now is 09:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com