Update text control on list form

Here’s my problem. I have a text control with a variable source expression on the vendor ledger entry form that shows prior years payments to that vendor. I open the ledger form and on the vendor form arrow thru the various vendors and the ledger form changes and updates as i go. so far so good. I am calling my code to calculate the variable from onOpenForm and OnAfterGetNextRecord. this works except when I move onto a vendor that has no Ledger entries. then I still have the previous vendors numbers in the calculated variable because there are no next records to get, so code in that trigger never fires and the form is already open (I know Onactivate would help but then they have to click the form to update). Is there a way i can set my calced variable to 0 when no records are found in the ledger for that vendor. thanks

Hi I asume the calculated variable is displayed on the vendor card??? Therefore the onaftergetnextrecord trigger should be fine for this purpose. Are you clearing your calculated variable before making any calculations? Try this Myvaiable := 0; IF ThereAreVendorLedgerEntries() THEN MyVariable := TotalPreviousPayments(); This task would be made much simpler and require no code if you use a flowfield. Hope I understood what you are trying to do Craig.

Should it not be in the trigger OnAfterGetRecord and as per the previous amswer why not just use a Flowfield? and a “Date Filter”? David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: www.mindsource.co.uk Edited by - David Cox on 2001 Mar 03 00:15:38

The text control is on the Vendor ledger form not the vendor form. The variable is a complex calculation that is not possible ina flow field. Is there any trigger that would always fire in this situation, even when there are no records in the vendor ledger entry table for that vendor. Thanks

I know this may be a silly question but how are you doing the calculation? With the Correct Key and a sum index field it should look a bit like this The Correct place for the code is “OnAfterGetRecord” A global Variable Called VendorNo Code 20 PmtAmt Decimal VendLedgEntry Record “Vendor Ledger Entry” OnOpenForm() VendorNo:=’’; PmtAmt:=0; OnAfterGetRecord() // New Vendor Only Calculate Once IF “Vendor No.” <> VendorNo then begin VendLedgEntry.RESET; VendLedgEntry.SETCURRENTKEY (“Vendor No.”,“Document type”,“Posting Date”); VendLedgeEntry.SETRANGE(“Vendor No.”,“Vendor No.”); VendLedgeEntry.SETRANGE(“Document type”,“Document Type”::Payment); VendLedgeEntry.SETRANGE(“Posting Date”,Calcdate(’-1Y’,WORKDATE),WORKDATE-1); // Multi Currency Ledger get “Amount (LCY)” Value VendLedgerEntry.CALCSUMS(“Amount (LCY)”) PmtAmt:=VendLedgEntry.“Amount (LCY)”; VendorNo:=“Vendor No.”; END; Use SETRANGE(Positive,TRUE) instead of Document Type to Include all types of “Payments and blank Document Types” Note: You should not use the Amount field because of “Currency Code” as a the Vendor may have been paid in different Currencies. Not using multi currency? Always code for it, they might start the day you finish your work. Hope this is of help! David Cox MindSource (UK) Limited Navision Solutions Partner Email: david@mindsource.co.uk Web: Edited by - David Cox on 2001 Mar 05 20:26:11