Stop code running if a field is not empty

Smashed_PumpkinSmashed_Pumpkin Member Posts: 47
edited 2004-04-22 in Navision Attain
Hi all,

I have some code on the Purchase Order form that runs each time a Vendor No. is entered. Basically the code looks at some new fields in the Vendor table where an alternate delivery address can be specified, and copies the contents to the PO header 'Ship-to address' fields.
Vendor.GET("Buy-from Vendor No.");
"Ship-to Name":=Vendor."Alt del addy - name";
"Ship-to Address":=Vendor."Alt del addy - add1";
"Ship-to Address 2":=Vendor."Alt del addy - add2";
"Ship-to City":=Vendor."Alt del addy - city";
"Ship-to County":=Vendor."Alt del addy - county";
"Ship-to Post Code":=Vendor."Alt del addy - postcode";

This works fine unless the Ship-to address already has something in it, in which case it is overwritten. How can I prevent this? Thanks in advance!

Comments

  • SbhatSbhat Member Posts: 301
    Hi,

    Just check if Ship-to address is blank then write the other details else leave it alone.

    Regards
    SB
  • DenSterDenSter Member Posts: 8,307
    I would make this depend on one of the fields, so your code would change from:
    Vendor.GET("Buy-from Vendor No.");
    "Ship-to Name":=Vendor."Alt del addy - name";
    "Ship-to Address":=Vendor."Alt del addy - add1";
    "Ship-to Address 2":=Vendor."Alt del addy - add2";
    "Ship-to City":=Vendor."Alt del addy - city";
    "Ship-to County":=Vendor."Alt del addy - county";
    "Ship-to Post Code":=Vendor."Alt del addy - postcode";
    
    To this:
    IF "Ship-to Name" = '' THEN BEGIN
      Vendor.GET("Buy-from Vendor No.");  
      "Ship-to Name":=Vendor."Alt del addy - name";
      "Ship-to Address":=Vendor."Alt del addy - add1";
      "Ship-to Address 2":=Vendor."Alt del addy - add2";
      "Ship-to City":=Vendor."Alt del addy - city"; 
      "Ship-to County":=Vendor."Alt del addy - county";
      "Ship-to Post Code":=Vendor."Alt del addy - postcode";
    END;
    
    hth
Sign In or Register to comment.