Fill up a global variable after lookup

tompynationtompynation Member Posts: 398
Hi, i have a form with a Field called Productcode.

This field has a table Relation With the table: Recept, Field ReceptItem


So when you press the lookup on the form and select a Recept,
the productcode gets filled up with the ReceptItem.

Now i would like that when the users selects a ReceptItem through the lookup, that i also get the ID of the Recept record

How can i achieve this?

Answers

  • garakgarak Member Posts: 3,263
    There are more Recept records with the same ReceptItem No. :?:

    If yes, the user can't validate manuel these field (not editable) and must lookup (or you open a form after validate if there are more then 1 Recept records with the ReceptItem which the user has enter).

    If no you can solve your problem with the OnAfterValidate Trigger of the field in your table. There you get the record id ("Recept records".setrange() ....) or you use a FlowField for this.

    if yes, back to non editable field. Here you can use the OnLookup() - trigger of your field. You dont use here the default lookup function by TableRelation, u use here your own.
    OnLookup() - trigger
    ReceptRecords.reset;
    ReceptRecords.setfilter(ID,YourRecRecId); //only if the field YourRecRecId is filled out and you will see the ReceptRecord for this id
    if form.runmodal(YourFormIdForReceptRecords,ReceptRecords) = Action::LookupOk then begin
      YourItemNo := ReceptRecords."Item No.";
      YourRecRecId := ReceptRecords.Id;
    end;
    

    Regards
    Do you make it right, it works too!
  • tompynationtompynation Member Posts: 398
    great, that piece of code was what i needed... \:D/

    Thanks
Sign In or Register to comment.