Stop code running if a field is not empty

Smashed_Pumpkin
Member Posts: 47
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.
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!
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!
0
Comments
-
Hi,
Just check if Ship-to address is blank then write the other details else leave it alone.
Regards
SB0 -
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;
hth0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions