Creating lookup to open a table list form or another...

robertadi
robertadi Member Posts: 8
I wrote some code on a lookup text box so i can be able to open a table list form or another, according the value of an option variable.
The source expresion of the lookup is a code variable in with I want to keep the value that I will take from the focus of the form the lookup will open.
Still, pushing the lookup does nothing, where do I go wrong?
I will paste the code i wrote on the "On Lookup" trigger:
IF (Partner = 22) THEN BEGIN
                          IF (FORM.RUNMODAL(22,Cust,PartnerNo) = ACTION::LookupOK) THEN
                             PartnerNo := Cust."No.";
                       END
ELSE IF (Partner = 27) THEN BEGIN
                               IF (FORM.RUNMODAL(27,Vend,PartnerNo) = ACTION::LookupOK) THEN
                                  PartnerNo := Vend."No.";
                            END;

Comments

  • ritz
    ritz Member Posts: 25
    please review the code....

    Though I am able to run this code

    IF (Partner = 22) THEN BEGIN
    IF (FORM.RUNMODAL(0,cust) = ACTION::LookupOK) THEN
    PartnerNo := cust."No.";
    END
    ELSE IF (Partner = 27) THEN BEGIN
    IF (FORM.RUNMODAL(0,vend) = ACTION::LookupOK) THEN
    PartnerNo := vend."No.";
    END;

    Thanks
    Ritesh Kumar Singh
    Thanks,

    Ritesh
  • robertadi
    robertadi Member Posts: 8
    I have reviewed the code with your changes but still no form is activated as the lookup is dead, doesn't work.

    It must be something else I've forgot to do...
    ;)
  • frede
    frede Member Posts: 80
    Would guess that Partner has no value since the code looks fine!

    Try debugging or a message('Partner is %1',Partner) before the code!

    Sorry if I'm being to "simple".. :oops:
    Regards,

    Henrik Frederiksen, Denmark
  • robertadi
    robertadi Member Posts: 8
    I have initialized partner with "0" before. :)
    It's not that... ](*,)
  • David_Singleton
    David_Singleton Member Posts: 5,479
    robertadi wrote:
    I wrote some code on a lookup text box ...

    Change it to a CASE structure as is the norm for Navision:
    CASE Partner of
      22: 
        BEGIN
           IF (FORM.RUNMODAL(22,Cust,PartnerNo) = ACTION::LookupOK)  THEN
              PartnerNo := Cust."No.";
        END;
      27:
        BEGIN
           IF (FORM.RUNMODAL(27,Vend,PartnerNo) = ACTION::LookupOK) THEN
              PartnerNo := Vend."No.";
        END;
      ELSE
         Message(sstrsubstno('No form found for partner %1',partner);
    end;
    

    Also I agree with ritz, in this case you should be using form 0
    David Singleton
  • robertadi
    robertadi Member Posts: 8
    I can't wait to try and see if it works. I think I can give u an answer tomorrow night or the day after tomorrow cause now I haven't exported what i've worked and don't have the report on my computer...
    Anyway, I'll tell as soon as I try it, untill then...

    thanks again people ;)