Why does space appear in concatenated string?

Hi, I have the following line in my code:

strNodeID = rsTreeViewAdd(strParentFIeld) & "N" & rsTreeViewAdd(strSubField) & str(intSubUnitCount)

Each of strParentField and strSubField refer to 8 character text fields.  Based on the code above, I would expect to get:

 11107001N110420012

But instead I get:
 11107001N11042001 2
(ie, there is a space before the final digit)

Can anyone tell me how to get rid of the space?  I tried using + instead of &, but it didn't help.
tmreiterAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
There might be a trailing spa ce in the field itself. Try passing the value through Trim() first:
strNodeID = rsTreeViewAdd(strParentFIeld) & "N" & Trim(rsTreeViewAdd(strSubField)) & Trim(str(intSubUnitCount))

Open in new window

0
jmcgOwnerCommented:
The str function includes a position for the sign (or space, when the number is not negative). You could use a different conversion using format:

strNodeID = rsTreeViewAdd(strParentFIeld) & "N" & rsTreeViewAdd(strSubField) & format(intSubUnitCount)

Open in new window

0
PatHartmanCommented:
Why are you converting intSubUnitCount to a string?  The & is specifically a concatenation function it will not try to add numbers the way the + will.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

tmreiterAuthor Commented:
Gentlemen, thanks for the quick responses; I've tried all of your solutions, and all of them work.  I'm a bit embarrassed I missed so many ways of fixing the problem...I've got a lot to learn.

What is the etiquette for assigning points?  I will probably use PatHartman's solution (leave intSubUnitCount as an integer) as the simplest, but since all of your solutions work, should I accept multiple solutions?
0
jmcgOwnerCommented:
You can split points or just give all the points to the one you consider the best answer. If you're using Pat's solution, none of the rest of us has much right to complain if you give all the points to that solution. Spreading the points can be a nice gesture, but it can get a little ridiculous sometimes.
0
tmreiterAuthor Commented:
Thanks again.  Since all of the solutions worked, I wanted to give at least a few points to each of you, although I've allocated most of them to PatHartman.
0
Gustav BrockCIOCommented:
The direct solution is to use CStr():
strNodeID = rsTreeViewAdd(strParentFIeld) & "N" & rsTreeViewAdd(strSubField) & CStr(intSubUnitCount)

Open in new window

/gustav
0
tmreiterAuthor Commented:
Yup, that works too.  

When looking at Cstr, I learned that Str includes a leading space for positive numbers, which I would not have guessed.
0
Gustav BrockCIOCommented:
That's one difference. Another is, that Str() accepts Null while CStr) doesn't.

/gustav
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.