Dear Experts, I received the following error upon selecting the Payment Vch option within the Voucher Entry Screen: "Cannot Understand...Bad Formula!... If Not ##ForceCheque "Force Cheque Mode" Else "Clear Cheque Mode". Basically, I want to add a Toggle Button during Payment Voucher entry to Auto-Set the "Transaction Type" as "Cheque" within the Bank Allocations screen. Currently, the default is e-FundTransfer for Parties having their Bank details stored in their Ledgers. I want to temporarily override this for making & printing bulk cheque payments to All Vendors. And Since I want add this button only for payment voucher entries, I added the condition ":$$IsPayment:$VoucherTypeName" to the Add Button statement, but it did Not add the button. And when I removed(commented) this condition, I got the 'Bad Formula' error. Also, it will be helpful if you can point out other errors that you noticed in below code. Here is the code: Code: [#Field: VchBankAlloc TransactionType] 'Set as: $$SysName:Cheque Add: Set ByCondition : (@@IsPayment AND ##SVSingleEntry AND $$InCreateMode AND ##ForceCheque): $$SysName:Cheque [System: Variable] ForceCheque: No [Variable: ForceCheque] Type: Logical Default:No ;;Persistent: Yes ;only temporary, not required across sessions. [Button : ForceChq] Key : Alt + Q Title : If Not ##ForceCheque "Force Cheque Mode" Else "Clear Cheque Mode" Action : Set : ForceCheque : NOT ##ForceCheque [#Form: Voucher] Add: Button: ForceChq ;;: $$IsPayment:$VoucherTypeName
Correct methodology is If ..... Then .... Else If Not ##ForceCheque Then "Force Cheque Mode" Else "Clear Cheque Mode".
Or you can Add OPTION in the Form level [Form : Voucher] Option : ForceChqBtn : $$IsPayment:$VoucherTypeName Then in that form definition -- Add your Button.
Thank you for catching that! no wonder it didn't work... I added the word 'THEN' to the syntax, and used the Inactive attribute, and it worked!! Better still, I made it an Optional Button in the Voucher form. Once again, thank you for that suggestion. Below is my updated code. Code: /* This code is set to alter default Transaction type to 'Cheque' for all payment voucher creations. To set this for All Voucher types i.e. Payment, receipt and Contra, make alterations (Uncomment commented lines and vice-versa) as noted in the suffixed comments of respective lines */ [#Field: VchBankAlloc TransactionType] Add: Set ByCondition : (@@IsPayment AND ##SVSingleEntry AND $$InCreateMode AND ##ForceCheque): $$SysName:Cheque ;Comment this line ;Add: Set ByCondition : (@@IsPayment AND @@IsReceipt AND @@IsContra AND ##SVSingleEntry AND $$InCreateMode AND ##ForceCheque): $$SysName:Cheque ; UNCOMMENT this line [System: Variable] ForceCheque: No [Variable: ForceCheque] Type: Logical Default: No ;Persistent: Yes ;Persistent Flag is to preserve the value across sessions (including Tally restarts). [#Form: Voucher] Add: Option : ForceChq : $$IsPayment:$VoucherTypeName ;Comment this line ;Add: Button: ForceChq ;UNCOMMENT this line [!Form: ForceChq] ;Comment this line Add: Button: ForceChq ;Comment this line [Button : ForceChq] Key : Alt + Q Title : If Not ##ForceCheque Then "Force Cheque Mode" Else "Clear Cheque Mode" Action : Set : ForceCheque : NOT ##ForceCheque Inactive : NOT $$IsPayment:$VoucherTypeName /*Kept this in case above code is modified to add 'Force Cheque Mode' Button to All Voucher types. It does not affect the optional Button setting. */