What can i do with OpenRecordset

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I want to have a query in VBA and after to open it.
i tried with OpenRecordset but doesn't work
 
Paul:

It sounds like you want to open the recordset in the query designer?

OpenRecordset, opens a result set of a query or SQL statement in memory,
where you can read or write (dependent on how it is opened,) against the
data in the recordset and database in general.

If you've successfully created a query definition and set its SQL and want
to open it in the user interface in the query designer, then you use a
different statement i.e. DoCmd.OpenQuery

If I've missed your point, then please supply more information and repost.
 
Yes right i want to create a query definition in VBa and
after to open it like i open when i create it in design
wiev.
I mean i don't want to have a lot of query in the query
window,but i want to create query with code and after to
open them
I tried with this but doesn't work
Sub a()
Dim SQL As String
SQL = "SELECT Categories.Price FROM Categories;"
DoCmd.OpenQuery "SQL", , acReadOnly

End Sub
 
Looks like you want to Createa query definintion
(CreateQueryDef).

dim qdfMyQry as QueryDef
set qdfMyQry = dbs.CreateQueryDef( NameOfQuery, SQL)

HTH

Hafeez Esmail
 
Back
Top