Access 2013 How do I reference a Local Variable in a 'Data Macro'

I am trying to run an 'After Update' data macro where I create a record in another table ONLY if any of 3 fields are changed.  Otherwise, I do not need to log any of the changes.

Problem - I am attempting use a 'local variable' that I set in the beginning of the data macro to tell me if indeed any of these fields have changed.   However, I never get a new record created.   I believe that I may not be referencing the local variable correctly.

I have attached a screen shot of the code for your review.  I hope this is a quick fix that someone out there can help me with.

Thank you.
lq
LocalVariable.jpg
LVL 1
Linda QuintanaAnalyst, Business Process Development and Continuous ImprovementAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
TempVars is generally the best way to refer to those in a Macro.

You can add a new item to the TempVars collection like this:

TempVars.Add "NameOfYourVariable", "Value of Your Variable"

You can also use SetTempVar in your Macro to do the same.

To refer to a TempVar:

TempVars("NameOfYourVariable")

https://msdn.microsoft.com/en-us/library/office/ff821458.aspx
0
Linda QuintanaAnalyst, Business Process Development and Continuous ImprovementAuthor Commented:
I'm not having any luck either way.   I have to create the 'temporary variable' when I change the specific variables on the form.   But when I reference it in the data macro I get a message that the variable cannot be found.  

Is it possible that I'm just not referencing it correctly.    I am using and IF statement    --    
If [TempVars]![tmpChanged] = "Yes"  then
   Create record....statement.
EndIf

Whether I reference the variable as a Local Variable or a Temporary Variable -- I get the same message.

Any ideas?   or thoughts?
lq
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Sorry, I believe that should be:

TempVar!tmpChanged
0
Linda QuintanaAnalyst, Business Process Development and Continuous ImprovementAuthor Commented:
I found that comparing and old value of  NULL   vs a new value was the culprit.   For some reason the system was unable to understand that the values were different.   Since the values expected were from a 'product list', I created a product that stated  NONE.   Once I changed all the values in the table that were originally   NULL   to   select the product   NONE.   I was able to make changes and have the logic understand that there was indeed a change.   Perhaps I could have done that by checking if the value were NULL, but it was easiest to just change the table.

I'll mark this as solved.

Thank you.
lq
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Linda QuintanaAnalyst, Business Process Development and Continuous ImprovementAuthor Commented:
--
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.