Access queries from VB

  • Thread starter Thread starter Clay B
  • Start date Start date
C

Clay B

Is there a way to run a query that is built in and resides
in access, from a VB front end using DAO? This may be the
wrong newsgroup, but I figured I would try here first.
Thanks!
- Clay
 
Clay-

If you can set a pointer to the database, you should be able to open a
recordset on any table or query. Assuming you have a variable named "db"
pointing to the database, you can open a recordset like this:

Dim rst As DAO.Recordset
Set rst = db.OpenRecordset("<name of query or table here>, dbOpenDynaset)

If the query you want to "run" is an "action" query, then use the Execute
method

db.Execute "<name of action query>", dbFailOnError

HTH...
--
John Viescas, author
"Microsoft Office Access 2003 Inside Out"
"Running Microsoft Access 2000"
"SQL Queries for Mere Mortals"
http://www.viescas.com/
(Microsoft Access MVP since 1993)
http://www.deanforamerica.com/site/TR?pg=personal&fr_id=1090&px=1434411
 
Back
Top