5 replies
by roc180
by chriskno
If you have repetitive updates, macro's work well. Keep your primary keys the way you have them. Open the database and click on the Macro tab and click on NEW. Click in the first row under the ACTION column and pick from the drop down box. Fill infive or six rows under the action column. Fill in:
SetWarning
TransferSpreadsheet
RunSQL
RunSQL
DeleteObject
Close
SetWarning - Use this to eliminate Access warnings when the macro runs and the duplicate records will not append. - Use the Action Arguments box at the bottom of the screen to set Warnings On to NO. This row is optional but a nice thing to set when you know the macro is working well.
TransferSpreadsheet - Use the Action Arguments box at the bottom of the screen to set the action to IMPORT, set the spreadsheet TYPE, give the new table that is being created a NAME, set the full path to include the spreadsheet name (EX: C:\Directory\spreadsheet.xls), and set field names to YES.
Go to the query tab and set-up two queries as if you were going to do the operation manually but don't run them. Then, while in the query window, go to view on the menu bar and select SQL view. Copy the SQL code.
RunSQL - In the Action Arguments of the first RunSQL, paste the code for the append query
RunSQL - In the Action Arguments of the second RunSQL, paste the code for the update query
DeleteObject - In the Action Arguments of DeleteObject, set the Object to TABLE and the Object Name to the name you gave the 'new imported table' in TransferSpreadsheet
Close - In the Action Arguments of Close, set the Object Type to TABLE, the Object Name to the name of the table you appended to, and Save to YES. This setting is optional but it is a nice touch to finish the macro off.
Close and save the Macro and you are done. It is a good policy to use Tools \ Database utilities \ Compact after you run the macro to reclaim HD space.
by chriskno
by chriskno
This discussion is closed to new replies.
Trending Windows Forum posts
Sort by Trending