I am trying to modify my forms to show the description of a Code, rather than the code itself. IE, on the customer card, for Payment Terms Code, I want to display the Description from the Payment Terms table rather than to show the Code. How can I do this, but keep the lookup based on the Code field? Any ideas?
Michael Martin
0
Comments
Instead we just made our codes more readable
ex codes:
Code - Description
COD - Cash On Delivery
NET30 - Net 30
1%10N30 - 1% 10 Days Net 30
B2B30 - Bill To Bill 30
30|60|90 - 1/3-30 Days 1/3-60Days 1/3-90 Days
etc
etc
Also renaming the code is a snap - it will go through the database & change the record everywhere. Should be a simple code to GET the description from the terms code table.
http://www.BiloBeauty.com
http://www.autismspeaks.org
I had a try in my own database and it works.
On the customer card form:
Create a global (e.g. 'PaymentText') Text (50)
Create a global (e.g. 'PaymentTerms') Record (Payment Terms)
Create a new text box and set the SourceExpr Property to PaymentText.
Put the following code in the OnAfterGetCurrRecord Trigger of the form: Now the Description will be shown in the text box. To get the lookup functionality you put the following code in the OnLookup Trigger of the PaymentText TextBox: If you want, you can delete the Payment Terms Code Text Box on the customer card. If you want to keep it on the form you have to do the first code additional into the OnValidate Trigger of the Payment Terms Code text box to update the 'PaymentText' after changing the Payment Terms Code on this lookup. Have a try.
Be careful with the above solution: the user can manually fill the PaymentText text box without an error, otherwise nothing will be changed in the database. Next time you call this record the correct payment term will be shown in the text box. To fix this put the following code in the OnValidate trigger of the PaymentText text box:
Now the user either could type the correct 'Payment Terms Description' (but he has to write it absolutely correct) or he types the 'Payment Terms Code' and all fields and text boxes will be filled correct.
Regards
Tim
This works perfectly. Thanks for the solution.
Michael
If you want to have it display immediately when the code is entered, you put a CALCFIELD("Pmt Terms Description") statement in the Code OnValidate and you're all set.
<edit>of course don't forget to set the new field to not be editable</edit>
RIS Plus, LLC
So you have to add the first code anyway. And you wouldn't have the functionality at a users input.
So you would need the last part of code, too. That means, that you only replace the PaymentText var with the FlowField at least.
But Michael, you have to edit the code. I got an error at inserting a new record. So you have to replace the first code with the following (OnAfterGetCurrRecord and OnValidate Trigger): That should work. Have fun!
Michael
in the onformat trigger add this code:
That's all, filtering possible