Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO & Query help

Status
Not open for further replies.

NewCoder2

Programmer
Apr 12, 2004
25
0
0
US
I'm sure this is easy, I'm just not getting it though.
All i want to do is use an ado connection in vba to create a record set based on my sql statement and then populate my variables with the data from the record set.

But I don't know if this should be in a sub, or it's own function, and I don't know how to put my recordset in to variables.

Thanks for anyt thoughts.

 
maybe this will help :

dim cnn as adodb.connection
dim rs as adodb.recordset
dim myvar as long

set cnn = myconnectionstring
set rs = new adodb.recordset

rs.open "SELECT customerID FROM tblCustomers", cnn

myVar = rs!customerID

rs.close

as to know where to place the code, that depends on what it will be used for.
set rs = nothing
set cnn = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top