Choose an Append Query Destination Table Dynamically in Microsoft Access
Question details
Choose one or more destination tables for an Access append operation based on form checkbox selections.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A form contains checkboxes that determine which tables should receive records from an append query.
- Observed behavior
- The append query cannot directly change its destination table based on the form selections.
Check the checkbox control names, destination table names, and source and destination field names in Access. Confirm that each destination table accepts the fields and data types returned by the SELECT statement.
Build and execute append SQL from the form's VBA code
Use a button's Click event to run an INSERT INTO statement for each selected destination table.
A saved append query has a fixed destination table. VBA can select from known table names, construct a separate SQL statement for each selected checkbox, and execute it.
The example assumes both destination tables have the same target fields. Replace the example checkbox, table, and field names with those in your database.
Open the form in Design View, select the button that should run the append, and open its Property Sheet. On the Event tab, set On Click to Event Procedure and click the builder button.
In the button's Click procedure, add code like the following. This example runs an append for each checked box: Dim db As DAO.Database Dim strSQL As String Dim sourceSQL As String Set db = CurrentDb sourceSQL = " (TransmittalID, RevisionID, [Date Sent]) " & _ "SELECT [Transmittal Details].TransmittalID, " & _ "[Transmittal Details].RevisionID, Transmittals.[Send Date] " & _ "FROM Transmittals INNER JOIN [Transmittal Details] " & _ "ON Transmittals.TransmittalID = [Transmittal Details].TransmittalID;" If Me.chkVizag.Value = True Then strSQL = "INSERT INTO [Revisions to Vizag]" & sourceSQL db.Execute strSQL, dbFailOnError End If If Me.chkOther.Value = True Then strSQL = "INSERT INTO [Revisions to Other]" & sourceSQL db.Execute strSQL, dbFailOnError End If
In the VBA editor, choose Debug > Compile, then return to Form View. Select a checkbox and click the button; open the corresponding destination table to verify the appended records. Repeat with both checkboxes selected if both tables should receive records.

Work with exported Access data in WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface and compatibility with common Microsoft Office formats. Export Access data to Excel to continue working with it in WPS Spreadsheets; WPS does not run or fix Access append queries.

Frequently Asked Questions
Can a saved Access append query change its destination table from a checkbox?
A saved append query has a fixed destination. Use the form's button Click event to choose a known table name, build an INSERT INTO statement, and execute it in VBA.
What happens if two destination checkboxes are selected?
In the example, each checkbox has its own If block, so clicking the button runs a separate append statement for each selected table.
Why should I use dbFailOnError with CurrentDb.Execute?
Pass dbFailOnError as the second argument to Execute so Access raises an error if the action query fails. This makes it easier to detect problems such as records that violate table constraints.
How do I fix a compile error in a multiline SQL string?
In the VBA editor, check that each SQL fragment is enclosed in double quotes and joined with an ampersand. Use a space followed by an underscore to continue a VBA statement onto the next line, then choose Debug > Compile.




