How can the answer be improved? Apr 24, 2014 Is there any way to trigger an action when a user edits a record? I know you can trigger an action OnLoad or OnCurrent, but I cannot seem to figure out how to trigger an action when the edit button is clicked. Any ideas or workarounds? Hi, Have you tried using a data macro? I'm not sure how that would help. My problem isn't the actual.
Macros, small snippets of code, automate repetitive tasks in a 'Microsoft Access' database and in other Microsoft Office applications. The use of macros enables an advanced user quickly create programming code quickly without having to write it from scratch.
Create an Update Query
Step 1
Step 2
Click on the 'Create' tab, and then on the 'Query Design' icon.
Step 3
Select 'table' from the 'Show Table' dialog box, and click 'Add.' After you have added the table to the query design, click 'Close' to remove the 'Show Table' dialog box.
Step 4
Double-click the field you would like to update. The query design updates with the field name.
Step 5
Click the 'Update Query' icon, a black exclamation point with a pencil beside it. You will now see the row 'Update To' in the query design.
Step 6
Input the text or value to which you wish to update the field on the 'Update To' line.
Step 7
Close the query. A dialog box appears asking if you wish to save the changes to the query. Click 'Yes.'
Give the query a name when prompted, and then click 'OK.'
Automate the Query Using a Macro
Step 1
Click the 'Create' tab, and then on the 'Macro' icon. A new macro window opens.
Step 2
Select 'Open Query' from the drop-down menu on the first line under the 'Action' column.
Step 3
Select the update query from the Query Name drop-down box in the Action Arguments area.
Step 4
Close the macro. A dialog box will appear asking if you wish to save the changes to the macro. Click 'Yes.'
Give the macro a name when prompted, and then click 'OK.'
Run Macro to Update Field Data
Step 1
Double-click the macro, which now shows in the database object window. You will receive an alert telling you that running the macro will update the data in your table.
Step 2
Click 'Yes' when the dialog box appears telling you the number of records included in the update.
Tip
- If you want to add other actions to the macro, use the next line under the 'Open Query' command in the macro window.
Video of the Day
Brought to you by Techwalla
More Articles
Hey all,
So I have an Excel macro that has the following:
which adds a new row (at row 2) and inserts 'ABC' in cell D2.
However, I need some way to embed this code behind an Access button in VBA. I understand that you can call an Excel Macro from Access, but the Excel document is changing often and will not always have the macro attached.
So my question is: How can I open the Excel document, insert a Row at line 2 and type 'ABC' in cell D2, and save and close the Excel document? ALL from Access VBA, It is not possible to have any macros saved in Excel.
My .xls file is named 'importtest.xls' and the sheet where I want to do this editing is 'Sheet1'
Thank you very much! Let me know if I was unclear, seems like a long question.