Setting filters

would like to set a filter on a table in code I want to take the Phone No. from the customer card and place it in the Contact card. I would like to know how i can set the keys in the contact table so i can filter on the customer table then assign the phone number. So far i have written Cont.SETCURRENTKEY(“No.”, “Company Name”); Cust.Cust.SETFILTER(Cust.“No.”, HELP PLEASE

Hi, try it the follwing way; cust.reset; if cust.find(’-’); repeat if cont.get(cust.“Primary Contact No.”) then begin cont.“Phone No.” := Cust.“Phone No.”; cont.modify; end; until Cust.next = 0; end; You neet not to set a current key, because “No.” is the only primary key field, so that you can use get. Hope this helps. Greetings, Frank

Thanks Frank… I tried your code and it compiled but it still doesn’t work. Are you putting this code on the form on OnAfterGetRecord or on the field on the form?

When do you want to transfer the telephone number to the contact ? I mean based on what action should that happen ? Normally the synchronization between customer, vendor and contact happens automatically. (if set up to do so).

Hi Ataris, I have done something similar before: on the contact card I wrote a function that looks up the businessRelation for the current contact. Funciton = “GetBusinessRelationInfo” call the funciton from OnAfterGetRecord on the Contact Card. Basically the funciton decides if the contact has business relations to Customer, Vendor, Bank account or nothing. Then if it is has a single Customer Relation (Table 5054 Contact business Relation) then populate a customer variable as “Cust.GET(ContBusRel.“No.”);”. On the Contact Card you can have a control that has a source to the Cust variable. Hope this helps?