I have a table that holds the information for the "Ricette" (literally prescriptions, practically checks provided to some of our customers by the public health system).
I think an example will come in handy to explain the situation.
A customer places an order for a total worth of 95€.
She has 2 checks each worth 49.50 for a total of 99.
I am building a form where a button makes the necessary calculations and saves the result in the "residue" field of said table.
Basically i'd like to be able to add "sforo" (that holds a negative value) to the residue field in another check, if available.
I think an example will come in handy to explain the situation.
A customer places an order for a total worth of 95€.
She has 2 checks each worth 49.50 for a total of 99.
I am building a form where a button makes the necessary calculations and saves the result in the "residue" field of said table.
Code:
Private Sub cmdAggiornaResiduo_Click()
Dim disp As Currency 'total availability, see Dsum below
Dim totPagamenti As Currency 'result of Dsum for all due payments
Dim sforo As Currency '<- this, keeps track of excess in payments
Dim risp As Integer
disp = (DSum("Residuo", "Clienti_Ricette", "IDCliente = " & Me.IDCliente))
If IsNull(DLookup("Importo", "Ordini", "IDRicetta = " & Me.IDRicetta)) Then
Me.txtResiduo = Me.ValoreRicetta
Else
totPagamenti = DSum("[Importo]", "Ordini", _
"[IDRicetta]= " & Me.IDRicetta.Value)
End If
With Me![txtResiduo]
If totPagamenti > disp Then
risp = MsgBox("Residuo insufficiente al pagamento!", 0, "Attenzione")
Else
sforo = Me.ValoreRicetta - totPagamenti
'Me.txtResiduo = Me.ValoreRicetta - totPagamenti
End If
Call .Requery
End With
End Sub
Basically i'd like to be able to add "sforo" (that holds a negative value) to the residue field in another check, if available.