Others

Run Microsoft Access Action Queries Without Opening Datasheets

Olivia MillerOlivia Miller Nov 25, 2026 868 views

Question details

Run append and delete queries without displaying datasheets, then update the relevant subforms.

Run Microsoft Access Action Queries Without Opening Datasheets
Product
Microsoft Access
Device & OS
not provided
Scenario
A Search button runs several action queries, including an append query that uses a crosstab as its source.
Observed behavior
A query datasheet can appear before the main form instead of showing only the refreshed subforms.
Before you start

Identify the saved append and delete query names in the Navigation Pane and find the Search button's Click event in the VBA editor. Confirm the names of the subform controls you want to update.

Solution 1Recommended

Use CurrentDb.Execute for action queries and requery subforms

Replace DoCmd.OpenQuery calls for append and delete queries to run them without opening datasheets.

Execute is appropriate for action queries, not for opening a crosstab or other SELECT query as a datasheet. An append query can still use a crosstab query as its source.

1
Open the button's VBA code

Open the form in Design View, select the Search button, and use Property Sheet > Event > On Click to open its event procedure.

2
Replace action query calls

Replace each DoCmd.OpenQuery call for an append or delete query with CurrentDb.Execute "QueryNameGoesHere", dbFailOnError. For example, use CurrentDb.Execute "Output_Total_App", dbFailOnError for the saved append query.

3
Requery the subforms

After all action queries finish, add Me!SubformControlName.Form.Requery for each subform, replacing SubformControlName with the control name on the main form. This example assumes the code runs in the main form's module.

4
Test the Search button

Save the VBA changes, return to Form View, and click Search. Verify that the action queries complete without opening datasheets and that the subforms show the updated records.

Use CurrentDb.Execute for action queries and requery subforms
Handle query errors: The dbFailOnError option raises an error if an action query fails. Add appropriate VBA error handling so users can see when the operation does not complete.
Free Microsoft Office alternative

Work with Office files in WPS Office

WPS Office is a free, lightweight alternative for everyday document and spreadsheet work, with a familiar interface and Office format compatibility for easier migration. It does not run Microsoft Access action queries or replace Access databases.

Review spreadsheet data in WPS SpreadsheetsOpen and edit Microsoft Excel XLSX filesUse a familiar interface for common office tasksWork with a lightweight, free office suite
microsoft office alternative - wps office

Frequently Asked Questions

Why does DoCmd.OpenQuery show a datasheet?

DoCmd.OpenQuery can open a query in Datasheet view. For saved append and delete queries, use CurrentDb.Execute with the query name instead to run the action without opening that view.

Can I use Execute on a crosstab query?

Execute is for action queries, not a crosstab SELECT query. If a saved append query uses the crosstab as its source, execute the append query by name.

How do I show the new records in a subform?

After the action queries finish, call Me!SubformControlName.Form.Requery from the main form's module. Use the subform control name, which may differ from the form object's name.

What does dbFailOnError do?

It tells Access to raise an error if the action query fails. Include VBA error handling in the button's Click event to report the failure.