By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,400 Members | 953 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,400 IT Pros & Developers. It's quick & easy.

Join two strings together

P: 3
Dear everyone,

I would like to join a prefix and a number which are separated by a "-" and do not know why it could not work for me. Can you please tell me why this code doesn't work:

=IIf([Prefix] Is Null,"",Trim$([prefix])) & - & Right$(Str$([Voucher No]+10000),4) & IIf([Suffix] Is Null,"",Trim$([Suffix]))

It is in a report and always as me to Enter Parameter "

Otherwise the following works but without a "-"

=IIf([Prefix] Is Null,"",Trim$([prefix])) & Right$(Str$([Voucher No]+10000),4) & IIf([Suffix] Is Null,"",Trim$([Suffix]))

Cheers.
Sep 7 '07 #1
Share this Question
Share on Google+
1 Reply


FishVal
Expert 2.5K+
P: 2,653
Dear everyone,

I would like to join a prefix and a number which are separated by a "-" and do not know why it could not work for me. Can you please tell me why this code doesn't work:

=IIf([Prefix] Is Null,"",Trim$([prefix])) & - & Right$(Str$([Voucher No]+10000),4) & IIf([Suffix] Is Null,"",Trim$([Suffix]))

It is in a report and always as me to Enter Parameter "

Otherwise the following works but without a "-"

=IIf([Prefix] Is Null,"",Trim$([prefix])) & Right$(Str$([Voucher No]+10000),4) & IIf([Suffix] Is Null,"",Trim$([Suffix]))

Cheers.
Hi, there.

Just a thought. Try to use IsNull() function instead of object comparisson operator "Is".
And BTW the expression could be simplified.

1. Concatenation operator "&" unlike math and logic operators doesn't work according to tristate logic.
e.g.
? "qwerty" + Null
Null
? "qwerty" & Null
qwerty

So check for Null value is not needed.

2. Expression
Expand|Select|Wrap|Line Numbers
  1. Right$(Str$([Voucher No]+10000),4)
  2.  
will return always the same as
Expand|Select|Wrap|Line Numbers
  1. Right$(Str$([Voucher No]),4)
  2.  
And, not concerning the problem, get reed of all this "$". This exists for backward compatability only and is supposed to be ceased in future.
Sep 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.