Lookup Coding

I am creating a customer card subform. The subform is for the Ship-to Address table. The it has a text box whose source expression is “Ship-to Address”.Code. I am attempting to make this text box a lookup box for the Ship-to Address List form. I want to be able to open to Ship-to Address form, select a different record, click OK, and have the newly selected record displayed as the active record in the Ship-to Address subform. I have added the following code to the OnLookup trigger of the Ship-to Address.code text box: OnLookup(VAR Text : Text[260]:wink: : Boolean ShipTo.SETRANGE(“Customer No.”, “Customer No.”); AddressList.LOOKUPMODE(TRUE); AddressList.SETTABLEVIEW(ShipTo); AddressList.SETRECORD(Rec); AddressList.RUNMODAL; CLEAR(AddressList); With this code, I am able to open the Ship-to Address List form, select a record and click OK but nothing is sent back to the subform. This seems like a pretty basic task. What am I missing? Thanks, Darin

Typically, a sub-form is shown as a one to many relationship where the main form is the ONE and the sub-form shows the many. It seems in your case you are only showing 1 at a time? At any rate you need to do something with the return value of ACTION. In your case try IF AddressList.RUNMODAL = ACTION::LookupOk THEN … after the THEN you can place whatever code you need to advance the record. Having said all this, I think you may wish to reconsider your approach and make it more “Navision like”. Bill Benefiel Manager of Information Systems Overhead Door Company billb@ohdindy.com (317) 842-7444 ext 117

Darin, It looks like you are trying to put the code into the form trigger, and Navision typically recommends putting your code into the table triggers. In any case you are missing this: IF AddressList.RUNMODAL = ACTION::LookupOK THEN BEGIN AddressList.GETRECORD(ShipTo); // do other processing here // keep in mind that onLookup does not call VALIDATE, so you may need this: VAlidate(“Ship-to code”, shipto.code); END; CLEAR(AddressList); Standard Navision uses this in a few places. If you are interested, look inside item journal line table. Alex

Hi after the lookup is done and if you want to use the OnValidate trigger for the same field then you have to use the Exit(true) statement in on the OnLookup() trigger. eg… IF AddressList.RUNMODAL = ACTION::LookupOK THEN BEGIN AddressList.GETRECORD(ShipTo); text := ShipTo.field; //any other processing exit(true); end; have a good day Kumar