Jump to content
  • 0

Trigger Only Enter Unique Values into fields within record


888Washington

Question

I'm looking to  only insert unique values within a record on update with a trigger.  Right now I have two tables set up with a trigger on insert/update.  When a user updates a field within the Employee's table, it copies all of the information from the current record into the Employee History table.  However, my users want to be able to see what fields were modified within the Employee History table.  The trigger currently just copies all fields (and values in those fields - most are text) from the current Employee's table to the Employee History table.  The user then can compare the current record in the employee's table with the employee history records and manually scroll through to find what values in each field are different, but this takes quite a bit of time. 

I would like the trigger to look at all the current values in the fields it is going to copy, if the values have not been changed (or are equal to the current values in the Employee History table), then do not update/insert those fields in the employee history table; otherwise update only the fields that have been changed.   This would ideally show only updated field values for each history record, instead of duplicating all of the field values.

Thank you for any assistance!

Capture.PNG

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Hey there, 

You can try something like what I built for my usage: 

image.thumb.png.8bbab87a431341eb7a1725db823378df.png 

In here, the trigger built in (aaa) table and on record update, fields updated are inserted into (aaaa) table. If Name was changed, Info field will be blank, and vice versa. ID is there to make sure records are connected, so kinda for relationships.

Feel free to copy-build such blocks for all of the fields that you have and would like to be ignored if they were not changed. 

Hope this helps! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...