You can use your favorite social network to register or link an existing account:
Or use your email address to register without a social network:
Sign in with these social networks:
Or enter your username and password
Forgot your password?
Yes, please link my existing account with for quick, secure access.
No, I would like to create a new account with my profile information.
Last week we outlined improvements to the Access 2010 macro designer, parameter support, and IntelliSense. These improvements build upon Access 2007 macro improvements of macro sandbox, embedded macros, TempVars, debugging, and support for error handling.
The natural next step in macros is to provide a model for business rules. Data macros allow developers to attach logic to record/table events (similar to SQL triggers). This means you write logic in one place and all forms and code that updates those tables inherit that logic. Here are a few data macro scenarios you might find in a typical Donations Management database:
A demo of creating a data macro is available here.
There were three primary design goals for data macros:
Table events fire on the BeforeChange (fires for inserts and updates), BeforeDelete, AfterInsert, AfterUpdate, and AfterDelete. You can create what we call Named macros that are associated with a table. They can be called from other data macros or UI macros. Named macros are essential for code reuse.
A key concept about data macros is they don’t have any UI. You can call Named data macros passing parameters from a UI macro but data macro can’t open a form or invoke a message box. They return errors that UI macros can catch and display to the user. These errors are also logged to the UsysApplicationLog table. This is a special table that keeps a history of data macro failures and other useful debug information you choose to write to it.
The BeforeChange and BeforeDelete events are designed to be fast, light-weight operations. You can look at old and new values in the current record and (after Beta1) compare them with a record in other tables using LookupRecord. You will also be able to use SetField to alter data before the change is committed (but on the incoming row of data only, not on the row returned from LookupRecord). They can prevent a record from being saved and raise custom error messages to the UI layer. Because they are designed to be fast and light-weight—you can’t iterate over a collection of records. Also, since the BeforeChange event fires for both inserts and updates, there is an IsInsert property that returns True for inserts and False for updates, in case your logic needs to handle them differently.
The AfterUpdate, AfterInsert, and AfterDelete events are designed for more extensive operations that require iteration and could take longer to run. Macros invoked from these events can look at and modify other records in the table or other tables. Old and updated values are available.
The After* events support the following program flow constructs:
The After* events support the following actions:
When a data macro runs, for example an AfterUpdate event, it is possible that the current record could be modified, which would prompt another AfterUpdate event. Data macros are limited to 10 levels of recursion, but we've provided an Updated("FieldName") function that returns True or False to help you trap any recursion manually by only reacting to changes in fields you care about (more details are below in the FAQ).
Finally, data macros cannot process multi-valued or attachment data-types.
Link Tables. Data macros are not supported on link tables; however, you can associate logic on a backend ACCDB database for typical front-end/back-end applications.
SQL Server. Data macros are not upsized to SQL Server. You might see third party tools fill this gap.
VBA Support. You cannot call VBA from a data macro—this would not support the goal of portability to other platforms. However, you can call a named data macro from VBA--including one with parameters.
Transactions Support. Data macros do not support transactions this release. Each operation is atomic.
Backwards compatibility. We made changes to Access 2007 SP1 so that it can read but not write data in tables with data macros.
Where is the log table? You can get to the USysApplicationLog table through right click in the navigation pane. Choose Navigation Options. Check Show System Objects. It is available in the status bar and Backstage in beta 2.
Old and Updated syntax. The way to see if field in a record has changed in a BeforeChange, BeforeDelete, AfterUpdate, and AfterDelete event is to use the “Updated” function. Here is a simple example how you would log that inventory has changed:
If Old.FieldName Products.AfterUpdate If Updated(“InventoryCount”) is true LogEvent =Products.InventoryCount – Old.InventoryCount & “ items were added to the inventory for product: ” & ProductID End If
Updated the post with minor details on 8/27/2009.
Removed outdated video, provided link to current video 11/22/2010.
Comments: (10) Collapse
So VBA support is not included because it would not support the goal of portability to other platforms, but data macros are not portable to SQL Server. So what other platforms are you referring to here?
So we can say that when we use split databases for multiuser environment we can transfer a lot of processing on server side. Is it true or datamacr0s will process locally. For example I have a datafile on server and front ends distributed on local systems where will the processing be done. I think it would be on server side so we can say upto some extent it can behave like server client. Now what I am thinking if datamacros are to run on server side then whether server machine (on which data file is located) will require access 2010 to be installed to run data macros. In case of 2007 we do not need access to be installed on machine where data file is located but only local computers running front end will require access to be installed. Any detail regarding this
>>Is it true or datamacr0s will process locally. Yes, the process local like all stuff for ACE. There is no change in how ACE (the new name for JET) works. When you update a table and there is a index on the table then that indexing routine always ran on your local machine. ACE/JET has always worked this way. You never did have to install ms-access or ACE/JET on the server. The access file sitting a shared folder on the server is not different then a power-point or excel file. You don’t have to install power-point on the server to open a power-point file in a shared folder from each PC on your network. This works the same for ms-access. So, Ms-access works the same as before. The indexing, and now trigger code will run on each computer that has ms-access installed. There is no need to install special software on the server side. You don't need access or anything on the server side. Albert D. Kallal
Edmonton, Alberta Canada
kallal@msn.com
what if we use access 2010 database with vb.net will it require to install access then
Disclaimer: I've not worked with Access inside .NET environment. However, I would be inclined to not to choose Access in this context. It was a good choice when Jet was a part of Windows Operating Systems and thus you can use it without having Access at all and it was a good solution for cases where we didn't want to go all out. But now it's Access's baby now and I don't know whether Jet will continue to be shipped with Windows but I wouldn't count on it so for that reason, I would sooner look to alternatives such as SQLite, MySQL or SQL Server Express for a fast & free & lightweight engine.
I personally do not see the point in the email function of the data macro. It puts up the warning that a program is sending an email on your behalf and gives the option of canceling it. Whats the point if the user can just stop it???? Maybe I missed something but does anyone know more about this function of the data macro?
Justin: A possible scenario is that you log an error into a table and, in some cases, have to warn someone else asap about that error, automatically sending the email. "Rolling back" the internal "transaction" should not roll back the email, since the email is not part of the transaction.
Justin: Sorry, I missread your question. Now I read it as it was not about the presence of sending an email, but about that the email process itself was not suitable.
While I understand that the process is executed locally, in the case of a split application, the tables, mainly Old, is global to all users, or I missed an important point? And if so, what tell me, locally, that Old.FieldName is related to ME (for VBA analogy) and not to another front end app having done some modif?
Peter - We will talk about other platforms later in the year. Khawar - You would need to install the ACE redist if you want to use it on a machine that doesn't have Office installed. Justin - your mileage may vary depending on your scenarios. There are some scenarios where the prompt is perfectly okay.
Comments: (loading) Collapse