After Insert Trigger (1 Viewer)

zezo2021

Member
Local time
Today, 02:23
Joined
Mar 25, 2021
Messages
381
Hello
after the record is inserted into DB, I want the current field value divided/ 100

Current Record Only
Not all records
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:23
Joined
Feb 28, 2001
Messages
27,138
In which context? Form? Query? VBA Code? Something else?
 

GPGeorge

Grover Park George
Local time
Yesterday, 17:23
Joined
Nov 25, 2004
Messages
1,829
Hello
after the record is inserted into DB, I want the current field value divided/ 100

Current Record Only
Not all records
What will you do with that calculation?
 

pbaldy

Wino Moderator
Staff member
Local time
Yesterday, 17:23
Joined
Aug 30, 2003
Messages
36,124
There is a sample db here:


I locked that thread since it's a duplicate.
 

plog

Banishment Pending
Local time
Yesterday, 19:23
Joined
May 11, 2011
Messages
11,638
You posted this in the SQL Server section. So here's a site to help you within that context:


However, you have another thread:


Which asks virtually the same question but within the context of an Access form. So which is it?
 

zezo2021

Member
Local time
Today, 02:23
Joined
Mar 25, 2021
Messages
381
You posted this in the SQL Server section. So here's a site to help you within that context:


However, you have another thread:


Which asks virtually the same question but within the context of an Access form. So which is it?

if possible the 2 solution one work with
frontend Access
backedn SQL SERVER
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:23
Joined
Feb 28, 2001
Messages
27,138
If you are asking for the same solution to work on both Access and SQL Server than you have to implement this in the front end - because back-end triggers between Access and SQL Server are quite different. So I repeat my question: In which context? Form, report, query, VBA code, or some other method of data interaction? Don't say "back-end" and "work in Access or SQL" because of the potential differences in the back-ends.

Better still, tell us the actual requirement in concept rather than telling us to divide by something. What are you doing?
 

plog

Banishment Pending
Local time
Yesterday, 19:23
Joined
May 11, 2011
Messages
11,638
This smells like a percent problem. Users are entering 70 but you want .7. If so, this can be solved via an input mask.

If not, why must you change what they enter? Why not just store their value and then do the math in a query or report when you need to use or display that value?
 

zezo2021

Member
Local time
Today, 02:23
Joined
Mar 25, 2021
Messages
381
This smells like a percent problem. Users are entering 70 but you want .7. If so, this can be solved via an input mask.

If not, why must you change what they enter? Why not just store their value and then do the math in a query or report when you need to use or display that value?
Yes.
Percent Issue
How can I solve this problem
 

plog

Banishment Pending
Local time
Yesterday, 19:23
Joined
May 11, 2011
Messages
11,638
I might have been wrong about an input mask. It's fixed via setting a property on the table:


Check out that thread and see if it works for you.
 

zezo2021

Member
Local time
Today, 02:23
Joined
Mar 25, 2021
Messages
381
Hello
work with Access Table Backend and front end access

-----------
my issue

frontend access and backend SQL server
 

Minty

AWF VIP
Local time
Today, 01:23
Joined
Jul 26, 2013
Messages
10,366
You store the correct value in the first place.

Format the control on the form to be Percent.
The end-user enters 7% it is stored as .07

No need for any triggers or anything else clever.
 

strive4peace

AWF VIP
Local time
Yesterday, 19:23
Joined
Apr 3, 2020
Messages
1,003
hi @zezo2021

best is control all user input with forms ... but if you do want something at the table level, it could be in BeforeChange -- something like this:

Table_BeforeChange_myPercent.png
 

OuterApply

New member
Local time
Yesterday, 17:23
Joined
Mar 10, 2022
Messages
15
@zezo2021
You really should try to post questions that are able to be answered, rather than just 1/100th of a complete thought and then waiting until everyone wrestles you to the ground and pries the rest of it out of you - that's laziness in the programming world.

What do you want to do? Where does the calculation go? Do you mean changing the value that was just inserted? Do you mean inserting a new record somewhere else? Do you mean displaying it on screen? Do you just need a calculated value in another column?

See, now I had to type a bunch of stuff that you should have explained originally, and so did 10 other people. Don't do that.
 

NauticalGent

Ignore List Poster Boy
Local time
Yesterday, 20:23
Joined
Apr 27, 2015
Messages
6,321
For S&G I tried to create a Table Macro/Trigger on a linked SP list...no joy.
 

strive4peace

AWF VIP
Local time
Yesterday, 19:23
Joined
Apr 3, 2020
Messages
1,003
adding on, @zezo2021 ... in case field has no value, you may want to wrap with COALESCE to avoid errors if it's Null

Code:
if Coalesce( [myfield],0 ) >1 then
 

Users who are viewing this thread

Top Bottom