In this example, we pretend that we created our own login system that stored the current user in tblCurrent. I will make a video on how to get the Windows login too, as this has been asked several times recently! cheers!
Great video! I'm thinking about changing my existing Audit Log to use this method. However I don't want the data macro to fire for every change, I think this could be addressed using a If Updated("myField") then RunDataMacro. I can't find many examples of how to use RunDataMacro, could you explain how this method works?
hi Sean. Congratulations on your videos. Question: is it possible through DataMacros to perform a personal function contained for example in a standard module? Thank you Lorenzo
Yes, you can do it. One way is to use SetLocalVar and setting the value to your VBA function. However, this crosses the line between the top and bottom layers of the application as I described in the beginning of the video. If you do it, it may sometimes break. Data Macros will trigger anytime data is updated, because they are tied to the ACE engine. If another program or script updates data, Data Macros will still trigger, but if you put a VBA function in there that process may have an error because your app is not running at the time data is updated. There can also be issues as to where your VBA resides, if the database is split, etc.
In our example, we pretend that we made John Doe log in to our app, and then we stored his name in tblCurrent while he uses the app. He is entering new cases for the other Case Workers, like a secretary.
Great question. I will do another video to show how to get the *Windows* username. In this example, we pretend that we are building an app. We made John Doe log in, using our own login form, and he is making appointments for the other Case Workers. When he logged in, we stored his name in tblCurrent.
Great video! I'm a database guy from long ways back (try DBASE II on a Radio Shack TRS-80) and finally getting back into Access. Do most of my work directly on the back end, so I'm thinking data macros may provide a solution for my current project, though I'm not sure how complex the final solution will be. I've got an inventory of components, purchased from multiple vendors on multiple invoices. I already have a query set up to list individual component costs and quantities per invoice. My goal is to accumulate the total costs of the components used in an end item (always the same list of components) and update the component inventory as each end item is completed. Essentially looking to manage inventory use on a FIFO basis. Any suggestions you might have would be greatly appreciated. Thanks, again, for the great videos.
Oh man, TRS-80! That was my computer when I was a kid. Dungeons of Daggorath in black and white 3D wireframes.. good times. On your project, you could definitely use a status change trigger. If the order changes status to complete, execute your query with all the build component counts to reduce inventory by those counts for each component. On the event/trigger you can capture the order or assembly ID then use that ID as a parameter in your update query, updating all of them in one shot. Interesting project!
Hi Sean. I was trying to change the form to launch my MS-Access to a particular form (In the Access option, Current Database Tab) but each time and I did that, I got this warning message "The value of a Display Form property was invalid and was not saved" and it returns the value to none even though I have done it countless times before now. It won't change even if I open it again and change it to the form I want. I need your help to resolve this issue as I am stuck.
You probably need to open your database in exclusive mode. Someone (even you perhaps) may have another database lock open on the file. Open Access > Open > Browse > in the dropdown next to Open, choose Open Exclusive If you can't, you may need to ask others to close the file or restart your machine to remove the lock. Great question!
It is possible that what you try to do after the delete gets an error. Perhaps you refer to the deleted record or something like that. What does your After Delete macro do?
@@seanmackenziedataengineering I want to store in the LOG table information about inserted/changed/deleted records from the DATA table. If I use the code Value = [DATA].[ID] in the After Insert or After Update event, it works, but if I use it in the After Delete event, then a new record is not created in the LOG table. No error will appear...
I want to write to the LOG table the insertion/change/deletion of a record from the DATA table. I use the expression Value = [DATA].[ID]. It works for both After Insert and After Update events, but not for After Delete. No record will be created, no error will appear...
@@vholas it is likely because you refer to a value that is already deleted when the macro runs. You might try Before Delete instead so you can use the value before it is deleted. Let’s see how it goes 🛠️
There is no CreateRecord action available for the Before Delete event. I also tried accessing the previous value in a field by using syntax [Old].[Field Name] , but this doesn't work either.
You are the only channel in my list where I have hit the bell icon :) Great Content
Wow, thanks!
Excellent!! How can I know the current user login in the FE?
In this example, we pretend that we created our own login system that stored the current user in tblCurrent. I will make a video on how to get the Windows login too, as this has been asked several times recently! cheers!
Great video! I'm thinking about changing my existing Audit Log to use this method. However I don't want the data macro to fire for every change, I think this could be addressed using a If Updated("myField") then RunDataMacro. I can't find many examples of how to use RunDataMacro, could you explain how this method works?
Good idea - you can use If Updated for this purpose. I’ll cover more like this in upcoming videos! Including RunDataMacro
Excellent as usual
Thanks!
Thanks for these great videos! Hope that sometime you can do a video on migrating tables/backend to SharePoint. Thanks again!
Great suggestion! Thanks!
hi Sean. Congratulations on your videos. Question: is it possible through DataMacros to perform a personal function contained for example in a standard module?
Thank you
Lorenzo
Yes, you can do it. One way is to use SetLocalVar and setting the value to your VBA function. However, this crosses the line between the top and bottom layers of the application as I described in the beginning of the video. If you do it, it may sometimes break. Data Macros will trigger anytime data is updated, because they are tied to the ACE engine. If another program or script updates data, Data Macros will still trigger, but if you put a VBA function in there that process may have an error because your app is not running at the time data is updated. There can also be issues as to where your VBA resides, if the database is split, etc.
In your video Sam did the update but in the log John was entered. ho can this be corrected to get the correct user name?
In our example, we pretend that we made John Doe log in to our app, and then we stored his name in tblCurrent while he uses the app. He is entering new cases for the other Case Workers, like a secretary.
@@seanmackenziedataengineering OK got it. Thanks
I have tried to use Environ("UserName") Instead of CurrentUser but unfortunately it seems that Environ functionset is not available for macros.
Great question. I will do another video to show how to get the *Windows* username. In this example, we pretend that we are building an app. We made John Doe log in, using our own login form, and he is making appointments for the other Case Workers. When he logged in, we stored his name in tblCurrent.
@@seanmackenziedataengineering Thats a great video Idea
Great video! I'm a database guy from long ways back (try DBASE II on a Radio Shack TRS-80) and finally getting back into Access. Do most of my work directly on the back end, so I'm thinking data macros may provide a solution for my current project, though I'm not sure how complex the final solution will be. I've got an inventory of components, purchased from multiple vendors on multiple invoices. I already have a query set up to list individual component costs and quantities per invoice. My goal is to accumulate the total costs of the components used in an end item (always the same list of components) and update the component inventory as each end item is completed. Essentially looking to manage inventory use on a FIFO basis. Any suggestions you might have would be greatly appreciated. Thanks, again, for the great videos.
Oh man, TRS-80! That was my computer when I was a kid. Dungeons of Daggorath in black and white 3D wireframes.. good times. On your project, you could definitely use a status change trigger. If the order changes status to complete, execute your query with all the build component counts to reduce inventory by those counts for each component. On the event/trigger you can capture the order or assembly ID then use that ID as a parameter in your update query, updating all of them in one shot. Interesting project!
That's really good. Thanks 👍
Glad you enjoyed it!
Hi Sean. I was trying to change the form to launch my MS-Access to a particular form (In the Access option, Current Database Tab) but each time and I did that, I got this warning message "The value of a Display Form property was invalid and was not saved" and it returns the value to none even though I have done it countless times before now. It won't change even if I open it again and change it to the form I want.
I need your help to resolve this issue as I am stuck.
You probably need to open your database in exclusive mode. Someone (even you perhaps) may have another database lock open on the file.
Open Access > Open > Browse > in the dropdown next to Open, choose Open Exclusive
If you can't, you may need to ask others to close the file or restart your machine to remove the lock. Great question!
Can you run a python script on an an event?
You can from a VBA event. See this example ruclips.net/video/4T6qOopbwcM/видео.html
@@seanmackenziedataengineering got it. Now can I chain data macro to vba macro to python?
Very useful! After Update and After Insert events work for me, but if I use After Delete nothing happens. What am I doing wrong? Thanks
It is possible that what you try to do after the delete gets an error. Perhaps you refer to the deleted record or something like that. What does your After Delete macro do?
@@seanmackenziedataengineering I want to store in the LOG table information about inserted/changed/deleted records from the DATA table.
If I use the code Value = [DATA].[ID] in the After Insert or After Update event, it works, but if I use it in the After Delete event, then a new record is not created in the LOG table. No error will appear...
I want to write to the LOG table the insertion/change/deletion of a record from the DATA table. I use the expression Value = [DATA].[ID]. It works for both After Insert and After Update events, but not for After Delete. No record will be created, no error will appear...
@@vholas it is likely because you refer to a value that is already deleted when the macro runs. You might try Before Delete instead so you can use the value before it is deleted. Let’s see how it goes 🛠️
There is no CreateRecord action available for the Before Delete event. I also tried accessing the previous value in a field by using syntax [Old].[Field Name] , but this doesn't work either.
Bonjour, je suivis votre tutoriel avec intérêt mais comment apprendre beaucoup plus en français
Merci d'avoir regardé ma chaîne ! RUclips fournit-il de bons sous-titres ?
🎉🎉🎉
Thanks!
Holly &^$*%&! You can do that in Access?!?!
You bet! Super cool feature, making Access even more powerful!