A simple If then else statement - or so I thought

JonA
Member Posts: 23
Hi,
I tried to add a simple IF statement to our sales invoice report, the intention is to display different text if payment method code is DD (Direct Debit).
I tried entering the code below but I get a syntax error, I have declared the variable mytext as text (50).
I really don't know what I'm doing! I'm trying to experiment on a backup copy - any help greatly appreciated, thanks. :?:
I tried to add a simple IF statement to our sales invoice report, the intention is to display different text if payment method code is DD (Direct Debit).
I tried entering the code below but I get a syntax error, I have declared the variable mytext as text (50).
IF "Sales Invoice Header"."Payment Method Code" = 'DD' THEN mytext := 'Direct Debit will be collected on' ELSE mytext := 'Payment is due on' END;
I really don't know what I'm doing! I'm trying to experiment on a backup copy - any help greatly appreciated, thanks. :?:
0
Comments
-
Sorry should have specified Navision 5.00
-
It should be
IF "Sales Invoice Header"."Payment Method Code" = 'DD' THEN mytext := 'Direct Debit will be collected on' ELSE mytext := 'Payment is due on';
0 -
To elaborate a little - you have an END without a BEGIN. Mohana's suggestion is to eliminate the END because there is no BEGIN. Another suggestion (which I personally prefer) is to always use BEGIN and END in IF statements, like this:
IF "Sales Invoice Header"."Payment Method Code" = 'DD' THEN BEGIN mytext := 'Direct Debit will be collected on'; END ELSE BEGIN mytext := 'Payment is due on'; END;
Note that without the BEGIN and END, the one statement in the TRUE part of the IF statement does NOT have a semicolon, because the TRUE and FALSE part of the IF are considered part of one statement.0 -
Thank you guys, Mohana and Denster - works perfectly either way, I appreciate your help.0
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