Share this Page URL

Chapter 9. Extending Your Use of Queries > Running Action Queries - Pg. 319

Extending Your Use of Queries See Also 319 9. 10. For more information about field and table properties, see Chapter 3, "Managing the Consistency, Format, and Integrity of Your Data." For more information about import- ing data, see Chapter 4, "Importing and Linking to Data." Click the View button on the toolbar to switch to Datasheet view. If you scroll down the list of records, you'll see that the recordset includes only orders for which the OrderDate is earlier than January 1, 1997. Switch back to Design view, and then click the Run button on the toolbar. You'll see a message indicating the action that the query is about to undertake, warning you that you can't undo this action. Click Yes in the message box. Close and save the query, naming it qryArchiveOrders. Open the OldOrders table in Datasheet view to see the records that have been appended. 11. 12. Switch the ArchiveOrders query to Design view, and then click SQL View on the View menu. The SQL statement that is used for an append query is an INSERT statement, shown here. An INSERT statement can include a SELECT statement (including a WHERE clause): INSERT INTO OldOrders ( OrderID, CustomerID, EmployeeID, OrderDate, RequiredDate, ShippedDate, ShipVia, Freight, ShipName, ShipAddress, ShipCity, ShipRegion, ShipPostalCode, ShipCountry ) SELECT Orders.OrderID, Orders.CustomerID, Orders.EmployeeID, Orders.OrderDate, Orders.RequiredD ate, Orders.ShippedDate, Orders.ShipVia, Orders.Freight, Orders.ShipName, Orders.ShipAddress, Orders.ShipCity, Orders.ShipRegion, Orders.ShipPostalCode, Orders.ShipCountry FROM Orders WHERE (((Orders.OrderDate)<#1/1/1997#)); The INSERT statement identifies OldOrders as the table to insert data into, lists the fields that will hold the data from the source table, and then specifies the records to be inserted.