Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on 

Table After Update event macro -- to get started

Question: How can I start a macro for ZIpCode field to run MsgBox "Hello World!"?

I will do more work after we are able to get the macro in place. Now, when the value of zip code changes, for now, it will message "Hello World."

User generated image User generated image
I need help working with the lower part by making the correct selections etc. to make the macro functional.
Microsoft AccessVBA

Avatar of undefined
Last Comment
Mike Eghtebas
Avatar of Robert Sherman
Robert Sherman
Flag of United States of America image

I don't think you can trigger code specifically from the ZipCode field this way.... What you are looking at are row-level events, so these would be triggered before or after an entire row is committed to the database.    These macros have limited functionality as they are intended to make updates to some other part of the data.  As such, I don't believe there is a way to call a MsgBox in the way you are asking.

If this were done at the form-level, through a form control's event model, then you could make a call to MsgBox or any other function.
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

ASKER

I am sure this feature is added to Access 10 and 13 but I am looking for some help how to get it started. I am very well aware of form events of all kinds and have been using them for over 10 year.

I have ignored macros before but here there is a functionality Microsoft has taken from SQL Server (triggers) and added them to Access and no one seems to know very much about it except the next expert who will show us how it is done.

Mike

Here a video explaining but it is not easy to follow it: https://www.youtube.com/watch?v=wqFYvsemoZo you may want to check it out.
ASKER CERTIFIED SOLUTION
Avatar of Robert Sherman
Robert Sherman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

ASKER

This is excellent. In the same file, I have added a new column (FName). for some reason, I hope you would figure out, it is not tracking it.

Could you please take a look at it to see why edits on FName are not tracked?

re:> looks to be a time consuming task, especially if you were to audit many different tables and/or fields.
On a later question, I will ask for solution to install such after update macros using VBA to see how far we can push it.

Thank you,

Mike
DataMacroExample-good.accdb
Edits on FName are not tracked because the OldValue and NewValue fields in TableAudit are of Numeric data type.   Possible workarounds would be to either change the Audit table so that those value fields accept Text (and then convert any numeric or other types when recording the old and new values) or create additional fields for tracking changes to Text fields, (for example, by adding "OldValue_Text" and "NewValue_Text" fields to TableAudit and setting those fields when dealing with Text.  

For the purposes of an audit log, storing everything as text is probably an acceptable solution.  

Here's a bonus tip:  If you go to the "File" Tab in Access, you will see a new "Application Log" button that will show you any errors that get generated by the Macros.. This helps when trying to debug any errors since the Macros don't provide any direct user prompting when errors occur.

Somehow, I don't think we're going to find much support for creating these macros via VBA...
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

ASKER

Here, with your help, upon update (zipcode for now), I am able to pass oldzip and newzip to an outside function to do with them whatever I want to. See the sample. This means "Hello World!" worked.

Thanks again to get me started.

Mike
DataMacroExample-rev1.accdb
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo