How to stop Access from truncating trailing spaces in textboxes?

  • Thread starter Thread starter John
  • Start date Start date
J

John

I notice that Access XP (SP3) truncates trailing spaces in textboxes. Is
there a way to turn this feature off? Thanks.

John
 
Hi, John.
I notice that Access XP (SP3) truncates trailing spaces in textboxes. Is
there a way to turn this feature off?

No. Saving trailing spaces isn't an efficient use of storage space. If
you'd like to have spaces between fields of data for display purposes, then
you may concatenate the spaces using VBA code or SQL. For example:

VBA:

Me!DisplayName.Value = Me!Title.Value & " " & Me!FullName.Value

SQL:

SELECT FirstName & " " & LastName AS FullName
FROM EMPS;

HTH.

Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address, so that a message
will be forwarded to me.)
Beware to those who use munged addresses: known newsgroup E-mail harvesters
for spammers are (e-mail address removed) and (e-mail address removed)
 
Hi, John.

I agree with Arvin on the use of a trailing space in a field, however, if
you need it for some downstream contatenation or calculated field, build it
on the fly in a query.

=[FirstField] & " " & [SecondField] or, for multiple spaces,

=[FirstField] & Space(5) & [SecondField]


Hope that helps.
Sprinks
 
I am sorry. I guess I should have been a little more specific. I use the
textbox to enter a substring that is used to search for a substring in
another larger string. This textbox substring may have trailing blanks.
I agree with everyone that normally you don't want to store strings with
trailing blanks. I assume from everyone's answer that there is no way to
turn off the automatic truncation of trailing spaces in textboxes?

John

Hi, John.

I agree with Arvin on the use of a trailing space in a field, however, if
you need it for some downstream contatenation or calculated field, build it
on the fly in a query.

=[FirstField] & " " & [SecondField] or, for multiple spaces,

=[FirstField] & Space(5) & [SecondField]


Hope that helps.
Sprinks

John said:
I notice that Access XP (SP3) truncates trailing spaces in textboxes. Is
there a way to turn this feature off? Thanks.

John
 
Hi, John.

No, there isn't a way. But you could add another textbox to input the
number of spaces to pad your search string with. Then in your command button
On Click procedure, you can build your search string:

Dim strMySearchString
strMySearchString = Me!txtMyInputString & Space(Val(Me!txtMyNumberofSpaces))
.....do your search

Hope that helps.
Sprinks

John said:
I am sorry. I guess I should have been a little more specific. I use the
textbox to enter a substring that is used to search for a substring in
another larger string. This textbox substring may have trailing blanks.
I agree with everyone that normally you don't want to store strings with
trailing blanks. I assume from everyone's answer that there is no way to
turn off the automatic truncation of trailing spaces in textboxes?

John

Hi, John.

I agree with Arvin on the use of a trailing space in a field, however, if
you need it for some downstream contatenation or calculated field, build it
on the fly in a query.

=[FirstField] & " " & [SecondField] or, for multiple spaces,

=[FirstField] & Space(5) & [SecondField]


Hope that helps.
Sprinks

John said:
I notice that Access XP (SP3) truncates trailing spaces in textboxes. Is
there a way to turn this feature off? Thanks.

John
 
Using a trailing asterisk, as in "MyString*" will find a trailing blank.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

John said:
I am sorry. I guess I should have been a little more specific. I use the
textbox to enter a substring that is used to search for a substring in
another larger string. This textbox substring may have trailing blanks.
I agree with everyone that normally you don't want to store strings with
trailing blanks. I assume from everyone's answer that there is no way to
turn off the automatic truncation of trailing spaces in textboxes?

John

Hi, John.

I agree with Arvin on the use of a trailing space in a field, however, if
you need it for some downstream contatenation or calculated field, build it
on the fly in a query.

=[FirstField] & " " & [SecondField] or, for multiple spaces,

=[FirstField] & Space(5) & [SecondField]


Hope that helps.
Sprinks

John said:
I notice that Access XP (SP3) truncates trailing spaces in textboxes. Is
there a way to turn this feature off? Thanks.

John
 
Back
Top