Microsoft Office Tutorials and References
In Depth Information
Action Queries in VBA
Action Queries in VBA
Everything about SQL that we’ve discussed so far in this chapter involves
select queries — queries that select data from tables to display but don’t
alter the data from the tables in any way. In this section, we discuss action
queries, which actually change the contents of tables.
Book III, Chapter 3 introduces the update and append forms of action queries.
Creating an action query
To execute an action query from VBA, you don’t need to define a recordset
or use a Recordset.Open statement. Instead, use the RunSQL method of
the DoCmd object as follows:
DoCmd.RunSQL SQLstatement
When you compose the SQL statement for an action query, follow the same
rules that you do for a select query, as described in “SQL and Recordsets,”
earlier in this chapter. Figure 5-6 shows a sample action query to update
records in Design view and SQL view.
Figure 5-6:
An update
query in
Design and
SQL views.
Search JabSto ::




Custom Search