Results 1 to 9 of 9
  1. #1
    vitale_mike is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    2

    Update Trigger

    I am trying to have an field in a table that holds the date time and is updated every time the record is updated. I'd like it to be done automatically via a macro/trigger. Any help?

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    make a select query that selects the data you wish to manipulate.

    press the button to turn it into an update query and put =date() in the field you're updating.

    add an event on the textboxes on the form for after update.

    create a macro to run your query.

  4. #4
    vitale_mike is offline Novice
    Windows 10 Access 2016
    Join Date
    Feb 2017
    Posts
    2

    Table Modifications

    I am doing direct manipulation on the table itself. Is it not possible to assign a macro after update? I have tried using the Table Tools - Table - After Update but 'Show All Actions' is greyed out and I don't have access to SetValue.


    Quote Originally Posted by Homegrownandy View Post
    make a select query that selects the data you wish to manipulate.

    press the button to turn it into an update query and put =date() in the field you're updating.

    add an event on the textboxes on the form for after update.

    create a macro to run your query.

  5. #5
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    The General Rule of thumb is that users should NOT be accessing/maintaining the data tables directly. In doing so, you can bypass a lot of controls, like this one you are trying to set up. You cannot set up macros or VBA to run against edits directly to the table.
    That is why all data interaction should be controlled through Forms, where you can do those sort of things.

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    In later versions you can use a data macro:

    https://support.office.com/en-us/art...d-f296ef834200
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    In later versions you can use a data macro:

    https://support.office.com/en-us/art...d-f296ef834200
    I stand corrected! It looks like in newer versions of Access, you CAN have macros run off of Table events (it didn't use to be this way).
    So, it looks like if you are using Access 2010 or newer, you may be able to do what you want!
    (Thanks Paul!)

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    No problemo! I certainly agree with not letting users work directly in tables.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Yeah, it's just good practice!

    That is the problem with some of the newer Access features. Some almost encourage "bad" (or at least not recommended) design (i.e. multi-value fields!).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Update fields using a field trigger
    By G4Stech in forum Import/Export Data
    Replies: 3
    Last Post: 10-23-2014, 02:18 PM
  2. Replies: 8
    Last Post: 06-05-2014, 12:08 PM
  3. After delete trigger
    By gpsram in forum Access
    Replies: 7
    Last Post: 01-26-2014, 04:09 PM
  4. event to trigger after new record
    By richlyn in forum Access
    Replies: 1
    Last Post: 03-02-2012, 10:26 AM
  5. date trigger
    By hyperionfall in forum Access
    Replies: 1
    Last Post: 08-08-2010, 01:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums