Link to home
Start Free TrialLog in
Avatar of joop123456
joop123456

asked on

Copying a number to a table when adding new record - 2

Hi!

How will the VBA be with one table extra in between?  But now from discount >> discount2
(the question, when adding a new related record to tblL2, I want the latest "discount" to be copied to "discount2" in an access form.)

qryZagerijen_REL_be
-ZagerijID (unique record)
-Discount

tblL1
-ContractAUTOID (unique record)
-ZagerijIDContract (one-to-many relation with unique field "ZagerijID" from "qryZagerijen_REL_be")

tblL2
-tbl2AUTO (unique record)
-ContractAUTOID_TL2  (one-to-many relation with unique field "ContractAUTOID" from "tblL")
-discount2



All records mentioned will be in the form's record source.

When making a query of the 3 tables it looks like this:
SELECT qryZagerijen_REL_be.Discount, tblL2.discount2, qryZagerijen_REL_be.ZagerijID, tblL1.ContractAUTOID, tblL2.tbl2AUTO, tblL2.ContractAUTOID_TL2, tblL1.ZagerijIDContract
FROM (qryZagerijen_REL_be INNER JOIN tblL1 ON qryZagerijen_REL_be.ZagerijID = tblL1.ZagerijIDContract) INNER JOIN tblL2 ON tblL1.ContractAUTOID = tblL2.ContractAUTOID_TL2;

ASKER CERTIFIED SOLUTION
Avatar of frankytee
frankytee
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joop123456
joop123456

ASKER

Hi frankytee!

Yes, every ZagerijID (=Supplier) has only one - latest - discount percentage.  Since it is changing
sometimes and when I enter an order, I want to work further in this order (tblL1 and tblL2) always
with the latest discount percentage available at that time.
In case this unique discount-% is changing, the discount2 fields shouldn't be updated. Only updated
(>copied) when adding a new record in tblL2.

(Percentages in a certain period stick should together with orders from that period, new orders might have new %-rates)
Forgot to mention, I noticed in the main-posting that I posted a similar question a while ago:
https://www.experts-exchange.com/questions/22895990/Copying-a-number-to-a-table-when-adding-new-record.html

Maybe helpfull...

Rgrds, Joop