Forum Discussion
Opening Balance query (grab record above)
- Jan 16, 2022Here is the complete query:
SELECT tblLCAmendHistory.*, Format(Nz(DSum("AmountOfChange","tblLCAmendHistory","letterOfCreditID=" & [tblLCAmendHistory].[letterOfCreditID] & " And [ID] < " & Nz([tblLCAmendHistory].[ID],0)),0),"Currency") AS [Opening Balance], [Opening Balance]+[AmountOfChange] AS [Closing Balance]
FROM tblLCAmendHistory
Hi Jurgen,
I think there is a difference in the comma and semicolon. This is why I have the syntax. Note I have replaced the semicolon with a comma in your formula above. I no longer have syntax. Also, I think I needed to replace "Valuta" with the word "Currency" to get the format correct. It seems likely the differences are since we are in different countries.
After making those edits, I think its very close but it needs to be tweaked a bit more and I have tried to modify to no avail. Its far outside my knowledge of queries like this. In the pic below, you can see what I am referring to. I need the Closing Balance to be the Opening Balance in the row below it. I hope it makes sense. Thank you very much for the help, Jurgen.
Opening Bal Jurgen: Format(Nz(DSum("AmountofChange","tblLCAmendHistory","letterOfCreditID=" & [tblLCAmendHistory].[letterOfCreditID] & " And [ID] < " & Nz([tblLCAmendHistory].[ID],0)),0),"Currency")
SELECT tblLCAmendHistory.*, Format(Nz(DSum("AmountOfChange","tblLCAmendHistory","letterOfCreditID=" & [tblLCAmendHistory].[letterOfCreditID] & " And [ID] < " & Nz([tblLCAmendHistory].[ID],0)),0),"Currency") AS [Opening Balance], [Opening Balance]+[AmountOfChange] AS [Closing Balance]
FROM tblLCAmendHistory
- Tony2021Jan 16, 2022Steel Contributorthat works. Amazing. You did that so easily. wow. thank you so much!