Question Log Record changes to a table when moving from the current record on the form (1 Viewer)

shadi73

New member
Local time
Today, 09:24
Joined
Nov 5, 2017
Messages
2
This seemed to me a very easy thing to do at the beginning, but it got complicated and very challenging. I am pretty new to MS Access, so -after struggling for many days- I hope to find the solution here.

Say we have a simple table like this:



Now, I need to track changes on this table on the record level and Log the changes in another table (Say Log table) like this:




Where track_type:

1 for add(insert)
2 for edit(update)
3 for delete

The changes(add/edit/delete) should be logged when the record on the Student Form is changed.

My Problem is that I am not able to generate the changes correctly.

My form has to refresh a lot which make excessive entries in the log table like this one:



As you can see, instead of one log for the insert, it takes two logs to insert a record.

I searched the net thoroughly, but I cannot find this kind of logging. I found information about logging on the field level, but this is not what I want. I know it may be better in most cases, but not for my case.

So, I will appreciate any guiding information/code.

a minimized database that focuses on the problem is attached and you can download it and see what I have tried and where I am stuck.

Notes:

1- Changes should be logged only when the user: - Move from the current record on the form. - Exit the form
2- Changes Should not happen while on the same record even if these changes committed to the Student table.
3- Refresh is unavoidable.
4- Audit Trail is not helpful if on the field level.
5- Data Macro is not helpful as changes can be committed more than once.
6- Before/After Insert or update event is problematic due to the M.Refresh. I need alternate method or how to do it correctly with these events.
7- It is highly appreciated to do the solution within the attached database.
8- Custom Navigation button are not an option.
 

Attachments

  • db_log.accdb
    704 KB · Views: 144
Last edited:

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 17:24
Joined
Jul 9, 2003
Messages
16,278
I noticed you have yet to receive a reply, so I'm bumping you post! A bit unusual considering that you have made such a well laid out and informative post. It might be because there's too much information! I personally haven't read through it properly, all I would add, is that if you are trying to record when things happen within your database then this is usually referred to as Auditing. You might find some relevant information by searching the forum for "audit" See my Blog here:- http://www.niftyaccess.com/searching-for-answers/ which explains how to use the excellent Google search facility within Access World Forums...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:24
Joined
May 7, 2009
Messages
19,230
search for allen browne's audit trail
 

isladogs

MVP / VIP
Local time
Today, 17:24
Joined
Jan 14, 2017
Messages
18,211
Just as an aside as you say you are new to Access, it isn't clear from the info provided whether the age field is the students' actual age or some kind of assessment age.

If its an assessment age, fine ....
However NEVER store a student actual age because of course it will change.
Instead, store the fixed value, DOB, and calculate the age when needed
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:24
Joined
May 7, 2009
Messages
19,230
here you may try
 

Attachments

  • aadb_log.zip
    47.6 KB · Views: 128

Users who are viewing this thread

Top Bottom