automate make table query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

how do i automatically run a make-table query? i tried doing the docmd.open
query command and it's giving me an error.

here it is: DoCmd.OpenQuery qryCat3, acViewNormal, acReadOnly

help!

thanks!
 
What error? There are a lot of possibilities.

Make-table queries are "action" queries. OpenQuery will run action queries
but not display them. Therefore, acViewNormal, acReadOnly
simply don't apply, but I don't know if that is what is causing your error.

If you really need to display the table, run the query (assuming you can get
it to run) and then open the created table as a 2nd step.

HTH,
 
how do i automatically run a make-table query? i tried doing the docmd.open
query command and it's giving me an error.

here it is: DoCmd.OpenQuery qryCat3, acViewNormal, acReadOnly

Note that MakeTable queries are VERY rarely actually necessary. You
can use a Select query as the recordsource for a Form or Report; you
can export from a Select query; you can base another query on a Select
query.

Why do you feel that a MakeTable query is necessary? And what
provision have you made to delete the table named in the MakeTable?

All that said... try

Dim db As DAO.Database
Dim qd As DAO.Querydef
Set db = CurrentDb
On Error GoTo Proc_Error
Set qd = db.Querydefs("qryCat3")
qd.Execute dbFailOnError
....

Proc_Exit:
Exit Sub
Proc_Error:
<handle the error condition appropriately>
Resume Proc_Exit
End Sub

The Execute method runs action queries, and lets you trap errors (such
as duplicate table names... <g>)

John W. Vinson[MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top