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

ADODB Set Query as Recordset 2

Status
Not open for further replies.

leonepaolo

Programmer
May 28, 2001
82
0
0
CA
Hi,

Is there a way to connect to a Query as with a Table using an ADODB connection.

To open a table I do the following

Set rs = New ADODB.Recordset
rs.Open sTable, cn

However that doesn't work with a query.

Any instruction and/or comments are appreciated.

Thanks in advance,
Paolo
 
Are you sure, that doesn't work with a query???
I've done it lots of times.
Even this.

rec.open "SELECT * FROM tblCountry " & _
"WHERE txtCountry Like 'A%'", _
CurrentProject.Connection, adOpenDynamic, AdLockOptimistic

are you trying to edit, a non editable query(Union,Aggregate)?
 
Hi Zion7

Thanks for your reply. I was trying to set the Recordset like that of a table, however:
"Select * From sQuery" does work.

Thanks for your help,
Paolo
 
It should work also with a query as is, as long as it doesn't have parameters, but I find that it sometimes need to be told what to expect.

[tt]rs.Open sQuery, cn, <cursortype>, <locktype>, adCmdStoredProc[/tt]

You might want to check out the CommandTypeEnums and ExecuteOptionEnums in the help file.

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top