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

Handling Nulls in a String

P: 83
I have a button that when pressed on a form, automatically reads statments and inputs a text sentence, based on other fields on the form. However, the variable only gets assigned a sentence if something is true, but null if it is not true. The below code sits after all of the criteria statements. The problem is that when the first four statements are null, the field has four spaces before the sentence. This is obvious because of the " " after ever variable. Is there an automatic function that only read a space if the previous variable is not null, or do I have to make an isnull statement for every " ".

[code]Me.Pending_Reasons = NoLE & " " & updttfs & " " & updtavs & " " & Illno & " " & updtfas & " " & updtmidl & " " & updtisc & " " & SurNoLE & " " & surupdtfs & " " & surupdtmidl & " " & surupdtemsi & " " & surupdtavs & " " & surupdtfas & " " & surupdtisc[code/]
May 15 '07 #1
Share this Question
Share on Google+
2 Replies


nico5038
Expert 2.5K+
P: 3,072
I've moved your question to the Access forum, thus it's visible by more experts.

For conditional filling you can use an IF statement, but also the "+" character instead of the "&".
When a Null value is attached to the string with a "+", then the whole string will be "nullified".

Thus you can use:
varible = "Name " & "middlename" + " " & ....

Nic;o)
May 15 '07 #2

NeoPa
Expert Mod 15k+
P: 31,476
Nice one Nico - Thanks. I never knew that :)
May 15 '07 #3

Post your reply

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