Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

Following code is not working if BATCHNO is NULL, get empty value in VarINAME.
Please help to solve this.

Thanks n regards,

Sunil

VB
//--- Code ----

Global StringVar VarINAME:="";

if not ISNULL({invoice01.INAME}) then
    VarINAME := {invoice01.INAME};

if not ISNULL({invoice01.BATCHNO}) then
    if {invoice01.BATCHNO} <> "" then
    VarINAME := VarINAME + ' Batch:' + {invoice01.BATCHNO};

if not ISNULL({invoice01.EXPDATE}) then
    if year({invoice01.EXPDATE})>1970 then
        VarINAME := VarINAME + ' Exp:' + totext({invoice01.EXPDATE},"MMM yy");
Posted
Updated 25-Feb-15 17:31pm
v2

Try if using parenthesis with multiline parts would help:
VB
if not ISNULL({invoice01.INAME}) then
    VarINAME := {invoice01.INAME};

if not ISNULL({invoice01.BATCHNO}) then
(
    if {invoice01.BATCHNO} <> "" then
    VarINAME := VarINAME + ' Batch:' + {invoice01.BATCHNO};
);

if not ISNULL({invoice01.EXPDATE}) then
    if year({invoice01.EXPDATE})>1970 then
        VarINAME := VarINAME + ' Exp:' + totext({invoice01.EXPDATE},"MMM yy");
 
Share this answer
 
Comments
Sunil Kumar P 26-Feb-15 23:12pm    
Thank you, I tried your suggestion. Problem is still there.
I got solution for the problem. By adding an else clause, surprisingly it works.

SQL
Global StringVar VarINAME:="";

if not(ISNULL({invoice01.INAME})) then VarINAME := {invoice01.INAME}
else VarINAME := "";

if not (ISNULL({invoice01.BATCHNO})) then
(
    if {invoice01.BATCHNO} <> "" then
        VarINAME := VarINAME + '  Batch:' + {invoice01.BATCHNO}
    else VarINAME := VarINAME + "";
)
else VarINAME := VarINAME + "";


if not (ISNULL({invoice01.EXPDATE})) then
(
    if year({invoice01.EXPDATE})>1970 then
        VarINAME := VarINAME + '  Exp:' + totext({invoice01.EXPDATE},"MMM yy")
    else VarINAME := VarINAME + "";
)
else VarINAME := VarINAME + "";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900