How to Use Data Macros to Track Changes to Field Entries in MS Access

Поделиться
HTML-код
  • Опубликовано: 3 окт 2022
  • In this episode, we continue our look at Data Macros by exploring how to log changes to a particular field in a table by logging each change in another table. We'll look at a price field in one table, then log each change to a product's price in a history table. This technique is requested often because it is one way that companies keep track of important fields in their databases.
    Related Videos:
    How to Use Data Macros to Track Changes to Field Entries in MS Access
    You are watching this video now!
    Data Macros in Microsoft Access
    • Data Macros in Microso...
    How to Use Macros in MS Access
    • How to Use Macros in M...
    Join me on Patreon!
    / mackenziedataengineering
    Demo of my BZ RDP Cloaker:
    www.patreon.com/posts/how-to-...
    Want the code from this video?
    mackenziemackenzie.com/downloads
    For developers looking for a new role, check out and sign up:
    www.toptal.com/qKaO2b/worlds-...
    Needing to hire technical resources for your project? Get the best:
    www.toptal.com/qKaO2b/worlds-...
    Contact form you can find at www.mackenziemackenzie.com/
    Follow me on social media:
    / mackenziedataanalytics
    / seamacke
    / seamacke
    / seamacke
    / psmackenzie
    Get Microsoft Office including Access:
    click.linksynergy.com/fs-bin/...
    Got a RUclips Channel? I use TubeBuddy, it is awesome. Give it a try:
    www.tubebuddy.com/seanmackenz...

Комментарии • 29

  • @miles6875
    @miles6875 Год назад +1

    Just ran into a use case for this video - excellent as always

  • @ssdusd
    @ssdusd Год назад +1

    Thanks! I love videos about Macros

  • @aimenbaig6201
    @aimenbaig6201 Год назад +1

    Thanks man!

  • @SharifulIslam-kg1mz
    @SharifulIslam-kg1mz Год назад +1

    I like you very much for your kind helping to us with ms access very useful and nice tips & tricks...

  • @interestingamerican3100
    @interestingamerican3100 Год назад +1

    Hot dayum son!!! I was just researching this topic!

  • @gerfer6261
    @gerfer6261 Год назад +3

    💕
    I do have something similar to this ( audit trail) but this is more handy
    It will be VERY handy if capture user name who done the changes too please

  • @farinatty
    @farinatty Год назад +1

    Very nice. What about a full audit trail. User who did change, old value new value etc.

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Год назад

      Good question! The old value will be logged here - if you query for a particular VehicleID in the history table, you will have a list of all previous values for that VehicleID. To get the user, you would need to have some single-row query to identify the current system user. I did an example in this video in tblCurrentUser (could be qryCurrentUser or however your program works: ruclips.net/video/wuyImulb_u4/видео.html

  • @ssdusd
    @ssdusd Год назад +1

    I like your videos! What is the deference between After Update And After Insert? When After Insert trigger? any Examples?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Год назад +1

      After Insert occurs once, just after a record is inserted. After Update occurs every time a record is updated. So if you insert and then update a record each day, after insert occurs on the first day, and then after update occurs on every day after.

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Год назад +1

      And, After Insert is the example in this video: ruclips.net/video/wuyImulb_u4/видео.html

  • @carimbo8604
    @carimbo8604 Год назад +1

    MacKenzie, would you please show us a tutorial on how to store data that changes along the years? For example, healthcare budget (public and private) over the years. Thank you in advance.

  • @aimenbaig6201
    @aimenbaig6201 Год назад +1

    Another question, how do you track two fields instead of one?

  • @ssdusd
    @ssdusd Год назад +1

    When we can use "RepaintObject Macro Action"?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Год назад +1

      If you have a process that "locks" or causes "not responding" so that your screen does not update while it runs, you can insert this action to cause the screen to update instead of staying frozen. It can be a little tricky to implement. One alternative is to pass back control to Windows by using DoEvents. For example, every n iterations of your loop. I did this here: ruclips.net/video/BPT-_H1ir6k/видео.html

  • @danielazzam
    @danielazzam Год назад +1

    Hello , You are keeping a history of the last price , which is the same price as in the tblVehicle .
    What if I need to keep history of how was the previous price ? There is no before update event here , does before change do the required ?

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Год назад

      Good question. The way it works is: if you change the same vehicle 2's price many times, you will see many rows for vehicle 2 in the tblPriceHistory. You can see the order of the prices by looking at the date field. I should have selected prices more times!

    • @danielazzam
      @danielazzam Год назад

      ​@@seanmackenziedataengineering Hello again . Thank you for your reply , but I guess you did not get my point .
      What I meant was what follows : let us consider that price of Mercedes is 6000 , and you changed it to 3000 only once , you will then see 3000 in both the main table and in the price history table . This way the original price (6000) was lost and never captured . This works fine if you want to track price change over time , but never captures the first time a price was changed

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Год назад

      You can always know the previous price by looking at the history table. Try it. Before update is not required.

    • @seanmackenziedataengineering
      @seanmackenziedataengineering  Год назад

      @@danielazzam the first time you change it, it will create a history record, because it was null then became the first price. Then it will also create a record for the second price. So, you will have both in your history table.

    • @danielazzam
      @danielazzam Год назад

      Yes you are right , I missed that point, that fields are originally empty , I was testing on existing data in time the price will be null originally
      Good day