Hi there,
Tried to search, but no luck. Not easy to find such question.
I have two related tables. (related with AcqID)
tblAcq and tblAcqDetail
In tblAcq I have information about the delivery and in tblAcqDetail delivered articles, price and quantity.
tblAcq
[AcqID] ; [Contractor]; [TransportCosts]; [CustomDuties]; [SumWithoutVAT]; [LimSUM](this total cost of shipment Goods+other cost)
I use VBA code to calculate [SumWithoutVAT] (sum of goods), then [VAT],
everything works well,
Next is I need to calculate actual cost for each product and record in. [tblAcqDetail].[LimPrice].
To calculate it I divede [TransportCosts]+[CustomDuties]/ by [SumWithoutVAT], and the result (percentage) I need add to cost of each product and store it in [LimPrice].
For example product cost 0.95 Euro I bought 100 pcs, transport is 5 EUR.
it means actual product cost is (0.95*100=95, then 5/95 approx. 0.052, then 0.95*0.052+0.95=1.0026. So actual product cost is 1.00 Eur.
Thanks for help.
Lower is my VBA Code.
Private Sub btn_Calculate_qryAcqDetail_Click()
On Error GoTo ErrorMsgBox
[SumWithoutVAT] = DSum("[AcqSum]", "[qryAcqDetail]", "[AcqID]=" & [Forms]![frmAcqDetail].[AcqID])
[VAT] = ([SumWithoutVAT] * [VAT%])
[AcqStatus] = "CALCULATED"
Dim perAcqLim As Single
perAcqLim = ([TransportCosts] + [CustomDuties]) / [SumWithoutVAT]
[LimPrice] = ([AcqPrice] * perAcqLim) + [AcqPrice]
Exit Sub
ErrorMsgBox:
MsgBox ("Calculation Failed")
End Sub
Private Sub Close_Doc_Click()
On Error GoTo ErrorMsgBox
Dim curAcqLim As Single
'Total cost of delivery
curAcqLim = [SumWithoutVAT] + [TransportCosts] + [CustomDuties]
[LimSum] = curAcqLim
[AcqStatus] = "CLOSED"
Exit Sub
ErrorMsgBox:
MsgBox ("Calculation Failed")
End Sub
Tried to search, but no luck. Not easy to find such question.
I have two related tables. (related with AcqID)
tblAcq and tblAcqDetail
In tblAcq I have information about the delivery and in tblAcqDetail delivered articles, price and quantity.
tblAcq
[AcqID] ; [Contractor]; [TransportCosts]; [CustomDuties]; [SumWithoutVAT]; [LimSUM](this total cost of shipment Goods+other cost)
I use VBA code to calculate [SumWithoutVAT] (sum of goods), then [VAT],
everything works well,
Next is I need to calculate actual cost for each product and record in. [tblAcqDetail].[LimPrice].
To calculate it I divede [TransportCosts]+[CustomDuties]/ by [SumWithoutVAT], and the result (percentage) I need add to cost of each product and store it in [LimPrice].
For example product cost 0.95 Euro I bought 100 pcs, transport is 5 EUR.
it means actual product cost is (0.95*100=95, then 5/95 approx. 0.052, then 0.95*0.052+0.95=1.0026. So actual product cost is 1.00 Eur.
Thanks for help.
Lower is my VBA Code.
Private Sub btn_Calculate_qryAcqDetail_Click()
On Error GoTo ErrorMsgBox
[SumWithoutVAT] = DSum("[AcqSum]", "[qryAcqDetail]", "[AcqID]=" & [Forms]![frmAcqDetail].[AcqID])
[VAT] = ([SumWithoutVAT] * [VAT%])
[AcqStatus] = "CALCULATED"
Dim perAcqLim As Single
perAcqLim = ([TransportCosts] + [CustomDuties]) / [SumWithoutVAT]
[LimPrice] = ([AcqPrice] * perAcqLim) + [AcqPrice]
Exit Sub
ErrorMsgBox:
MsgBox ("Calculation Failed")
End Sub
Private Sub Close_Doc_Click()
On Error GoTo ErrorMsgBox
Dim curAcqLim As Single
'Total cost of delivery
curAcqLim = [SumWithoutVAT] + [TransportCosts] + [CustomDuties]
[LimSum] = curAcqLim
[AcqStatus] = "CLOSED"
Exit Sub
ErrorMsgBox:
MsgBox ("Calculation Failed")
End Sub