Dear All,
When doing a General or Purchase journal, I have an extension whereby when I select "Account No." field, the GL account attached to respective posting group i.e. vendor posting group needs to be retrieved and its balance read. My issue is when I select the Account Type i.e. vendor, I get an error below before I select the vendor account. But if the Vendor account type is default in my journal line, I don't get error ,I am allowed to select the vendor account and my code works as expected. I need the liberty to select the account type of my choice i.e. vendor, employee etc with no error so I can the vendor of my choice or employee without this error. I don't understand why this error is coming if I haven't selected the vendor or employee himself.
Code extract
begin
If "Account Type" = "Account Type"::Vendor then
begin
If Vend.Get(Rec."Account No.") then
If VendAccPostGrp.Get(Vend."Vendor Posting Group") then
Message(VendAccPostGrp."Payables Account");
GLAcc.Get(VendAccPostGrp."Payables Account");
GLAcc.SETRANGE("Date Filter",0D,TODAY);
GLAcc.CalcFields(Balance);
End
end
Looks like the Posting Group does not have Cost Account setup, try the below code
If "Account Type" = "Account Type"::"Fixed Asset" then
Begin
If FA.Get(Rec."Account No.") then
Begin
If FaAccPostGrp.Get(FA."FA Posting Group") then
Message(FaAccPostGrp."Acquisition Cost Account");
IF FaAccPostGrp."Acquisition Cost Account" <> '' then begin
GLAcc.Get(FaAccPostGrp."Acquisition Cost Account");
GLAcc.SETRANGE("Date Filter",0D,TODAY);
GLAcc.CalcFields(Balance);
end;
End
End
Any idea/Suggestion?
Here is the codes
If "Account Type" = "Account Type"::"Fixed Asset" then
Begin
If FA.Get(Rec."Account No.") then
Begin
If FaAccPostGrp.Get(FA."FA Posting Group") then
Message(FaAccPostGrp."Acquisition Cost Account");
GLAcc.Get(FaAccPostGrp."Acquisition Cost Account");
GLAcc.SETRANGE("Date Filter",0D,TODAY);
GLAcc.CalcFields(Balance);
End
End
Please send me your code, looks like you are executing your code irrespective of Account Type, You need to check Account type and have that a main IF condition with begin end.
Suresh,
Here is the screenshot
Are you still getting error? send us the screenshot of it.
Thank you very much.This worked on other Account types except Fixed assets I don't know why.
If FA.Get(Rec."Account No.") then
Begin
If FaAccPostGrp.Get(FA."FA Posting Group") then
Message(FaAccPostGrp."Acquisition Cost Account");
Your if statement should be in begin end , you execute all the below code only when you get the vendor record
If Vend.Get(Rec."Account No.") then begin
end
Sohail Ahmed
1,169
YUN ZHU
1,006
Super User 2025 Season 1
Mansi Soni
830