Microsoft Access VBA Macro Programming

(Tina Sui) #1
What sort of uses could you put this to within your application? If you had a table that
collected data to work out something like a risk weighting, you could easily use this
methodology to calculate the risk weight based on the data that the user entered. It allows you
to use a calculated field based on other fields within the table.
You can also use the table macros to create records in other tables as the user enters data
into the original table. Create a second table with a single numeric field called Number2Copy.
Save this astblTableMacroCopy. You will not need a primary key for this example.
Open your original table, tblTestTableMacro, in design view and click Design in the
Access menu. Click Create DataMacros in the Field, Record, and Table Events group of the
ribbon, and then click After Insert.
Click the Add New Action drop-down at the bottom of the design window and select
Create Record. Your design window will now look like Figure 13-5.

170 Microsoft Access 2010 VBA Macro Programming


Figure 13-5 The Create Record action
Free download pdf