Updating record when opening a Form
Rodericks
Member Posts: 6
Hi all!!
I need to update some records in a table when I open a form, I put some code on the OnAfterGetCurrRecord() trigger:
BankAccLedger.SETCURRENTKEY("Bank Account No.");
BankAccLedger.SETRANGE("Bank Account No.","Bank Account No.");
BankAccLedger.SETRANGE("Posting Date",01011900D,"Statement Date");
BankAccLedger.CALCSUMS(Amount);
"Bank Ending Balance" := BankAccLedger.Amount;
Difference := "Statement Ending Balance" - "Bank Ending Balance";
BankAccLedger.MODIFY;
but we I run it, I get this error:
"You cannot make any changes in the database until a transaction has been started"
It seems that the MODIFY instruction is not allowed here.
I have unsuccessfully tried this in every trigger form the form
How can I update the record when opening the form?
Thanks-
Rod.
I need to update some records in a table when I open a form, I put some code on the OnAfterGetCurrRecord() trigger:
BankAccLedger.SETCURRENTKEY("Bank Account No.");
BankAccLedger.SETRANGE("Bank Account No.","Bank Account No.");
BankAccLedger.SETRANGE("Posting Date",01011900D,"Statement Date");
BankAccLedger.CALCSUMS(Amount);
"Bank Ending Balance" := BankAccLedger.Amount;
Difference := "Statement Ending Balance" - "Bank Ending Balance";
BankAccLedger.MODIFY;
but we I run it, I get this error:
"You cannot make any changes in the database until a transaction has been started"
It seems that the MODIFY instruction is not allowed here.
I have unsuccessfully tried this in every trigger form the form
How can I update the record when opening the form?
Thanks-
Rod.
0
Comments
-
Why would you want to write code like this?
a. Your bank account balance should Always match your ledger
b. If you want to do some calculation, why do you want to save them in the database like this?
In Dynamics NAV we have transactions in validation triggers and codeunit processes.
My suggestion would be to investigate best practices in how to develop in Microsoft Dynamics NAV
I'm doing a virtual introduction to NAV in two weeks.
http://decisions.msdynamicsworld.com/se ... ion-design0 -
Rodericks wrote:BankAccLedger.SETCURRENTKEY("Bank Account No.");
BankAccLedger.SETRANGE("Bank Account No.","Bank Account No.");
BankAccLedger.SETRANGE("Posting Date",01011900D,"Statement Date");
BankAccLedger.CALCSUMS(Amount);
"Bank Ending Balance" := BankAccLedger.Amount;
Difference := "Statement Ending Balance" - "Bank Ending Balance";
BankAccLedger.MODIFY;
To which table does "Bank Ending Balance" belong?
You are modifying BankAccLedger without a FIND command?
I agree with Mark. You should reconsider where your code should be located.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 322 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
