Run Query

  • Thread starter Thread starter MichaelM
  • Start date Start date
you can find this info on MS Access Help

On the click event of your command button

Private Sub cmdButtonName_Click()
' here you can type something for error handling

DoCmd.OpenQuery queryname[, view][, datamode]

End sub
hth,
gr
 
To "run a query" the query needs to be an Action Query, such as a Make Table
or Update query.

CurrentDb.Execute "NameOfQuery", dbFailOnError

Without the last item, you won't get an error message if the query doesn't
work. There will be no prompt before running this query, it will simply run
and make whatever changes it should make. In lieu of the NameOfQuery, you
could also use a SQL statement.

--
Wayne Morgan
Microsoft Access MVP


gr said:
you can find this info on MS Access Help

On the click event of your command button

Private Sub cmdButtonName_Click()
' here you can type something for error handling

DoCmd.OpenQuery queryname[, view][, datamode]

End sub
hth,
gr
-----Original Message-----
How do I write the syntax to run a query from a command
button in a form?
.
 

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