text box trims trailing spaces

  • Thread starter Thread starter WD Rudman
  • Start date Start date
W

WD Rudman

I have a text box on a form meant to be used to add a prefix string to a
particular field. I noticed that no matter what I put in the box, it always
trimmed out any trailing spaces I may have typed in. (Which is no problem, I
add back the space in the concatenation.)

I'm just wondering if this is by design, if I missed a property setting
somewhere, or just how it happened to get coded up when they built the
product?
 
No, there is nothing to "turn off"
What is the intent of saving trailing spaces in your table? That is only a
waste of disk space.

If you can tell me how you want to use these trailing spaces, I can show you
how to handle it easily without a lot of coding.
 
Thanks, but it is already handled.

The intent is a box on a form where users can specify a string "prefix" to
be appended to text from another field = "Example: " & [text field]

Because of the built-in trim, I have to add: & " " &

No biggie, but it is inelegant programming (the text box should take exactly
what is typed).


Thanks for the replies.
 
WD Rudman said:
Thanks, but it is already handled.

The intent is a box on a form where users can specify a string "prefix" to
be appended to text from another field = "Example: " & [text field]

Because of the built-in trim, I have to add: & " " &

No biggie, but it is inelegant programming (the text box should take
exactly
what is typed).

I hope you do not think that you've given us all the details to know what is
typed, and from where the " " is being dropped, because you haven't, and you
haven't indicated _where_ you have to add & " " &. If the " " is the last
character you typed in the Text Box, it is not "inelegant programming", it
is "working as designed" . . . you have to understand that Access is what it
is, not what any of us might prefer it to be.

If that Text Box is bound to a Field in a Table, and you add back a " " at
the end, it's likely to be dropped when the value in the Text Box is saved,
IIRC.

Larry Linson
Microsoft Office Access MVP
 
The only thing not "elegant" is the use of & " " &
VBA has to work harder and take longer to do it that way because it has to
create a variable on its own with the value of a space, then concatenate it
into the string.
Better coding style would be to either instanciate a constant:

Const conOneSpace As String = " "

& conOneSpace &

Or use the Space function

& Space(1) &

What you are experiencing is by design. As Larry points out, it is what it
is.
--
Dave Hargis, Microsoft Access MVP


WD Rudman said:
Thanks, but it is already handled.

The intent is a box on a form where users can specify a string "prefix" to
be appended to text from another field = "Example: " & [text field]

Because of the built-in trim, I have to add: & " " &

No biggie, but it is inelegant programming (the text box should take exactly
what is typed).


Thanks for the replies.


Klatuu said:
No, there is nothing to "turn off"
What is the intent of saving trailing spaces in your table? That is only a
waste of disk space.

If you can tell me how you want to use these trailing spaces, I can show you
how to handle it easily without a lot of coding.
 
Hi,

I know this is old thread, but i have the same problem and need the spaces to show in the textbox as they were typed.
My use of this textbox is as filter for a form after each key stroke. As it trims the spaces i can't filter by phrase like "a b"...

is ther any other solution?
I'm using access 97...

thanks.
 
Back
Top