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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Recordset based on query 1

Status
Not open for further replies.

cmayer10

Technical User
Aug 8, 2014
9
US
Hi All,
To open a recordset based on a table I typically use:

Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "Select * from [my_tbl]", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

How do I do something similar if I need to pull records from an existing query in my DB? Assume I want all records/fields from the query.

Thanks,
Collen
 
I would try:

Code:
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "Select * from [my_query]", CurrentProject.Connection, adOpenKeyset, adLockOptimistic

You may get errors if you have any parameters.

Duane
Hook'D on Access
MS Access MVP
 
Thanks for the post. Parameters were the problem with my code.

Collen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top