ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to iterate through results of SQL Query (https://www.excelbanter.com/excel-programming/388512-how-iterate-through-results-sql-query.html)

David Wessell

How to iterate through results of SQL Query
 
Hi,

Easy question here, but I'm not finding any examples..

If I've just placed a SQL query, how can I iterate through the results
using VBA?

rs.Open "SELECT * FROM generic table", _
dbMain, adOpenKeyset, adLockPessimistic

---

THanks
David


Vergel Adriano

How to iterate through results of SQL Query
 
David,

try something like this:

While Not rs.EOF
'do something with the current record. i.e.
Debug.Print rs(0)
'move to the next one
rs.MoveNext
Wend


--
Hope that helps.

Vergel Adriano


"David Wessell" wrote:

Hi,

Easy question here, but I'm not finding any examples..

If I've just placed a SQL query, how can I iterate through the results
using VBA?

rs.Open "SELECT * FROM generic table", _
dbMain, adOpenKeyset, adLockPessimistic

---

THanks
David



David Wessell

How to iterate through results of SQL Query
 
Vergel,

Thanks a ton.. That's perfect!


[email protected]

How to iterate through results of SQL Query
 
On May 1, 3:03 pm, Vergel Adriano
wrote:
David,

try something like this:

While Not rs.EOF
'do something with the current record. i.e.
Debug.Print rs(0)
'move to the next one
rs.MoveNext
Wend

--
Hope that helps.

Vergel Adriano



"David Wessell" wrote:
Hi,


Easy question here, but I'm not finding any examples..


If I've just placed a SQL query, how can I iterate through the results
using VBA?


rs.Open "SELECT * FROM generic table", _
dbMain, adOpenKeyset, adLockPessimistic


---


THanks
David- Hide quoted text -


- Show quoted text -


Hey Buddy,
THaks a lot. It helped me just now



All times are GMT +1. The time now is 05:16 PM.

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