Prevent first character = SPACE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Access 2002 user,
I have a data entry form where users frequently use Copy and Paste
functionality to populate text boxes on the form.

Users are copying a space before the text, and since I use these fields to
LINK or join to other tables/queries.... it's not workin out so well.

How can I check if the first character or two is = blank and if it is, trim
those spaces out (Text field)?

Thank you
 
Private Sub Text0_AfterUpdate()

If Not IsNull(Me!Text0) Then
Me!Text0 = LTrim(Me!Text0)
End If

End Sub

Replace 'LTrim' with 'Trim' if you want to trim trailing spaces too.
 
Works very well. Thank you.

Brendan Reynolds said:
Private Sub Text0_AfterUpdate()

If Not IsNull(Me!Text0) Then
Me!Text0 = LTrim(Me!Text0)
End If

End Sub

Replace 'LTrim' with 'Trim' if you want to trim trailing spaces too.
 
You're using a text field that people feel the need to C&P for linking?
That is lousy database design that is going to leap up and bite you on the
bum. You'd be better off rethinking your table structure.
 
Well Rob,
I have been reading posts on this site for about a year now. And this is by
far the worst. Even ignorant people realize that if you don't have anything
nice to say, don't say it. Or in today's world, If you don't have anything
to contribute, DON'T!

First of all, who are you? You know very little about the situation and my
database structure. What is the purpose of your post. You offer no advice,
just cheap shots. You are dead wrong, the purpose of C&P is not to LINK two
tables together, but to allow the user to insert a large amount of data into
a field from a source outside of the database. The TRIM will allow future
users who search for the project to find the project. Project "ABC" is
different that project " ABC". It is difficult for the user to visualyl
identify that there is a space before the project name when they enter the
project. So if they enter " ABC", and later search for project "ABC" it will
say, no project found. The like "*" & [Project] & ""*" was not a good option
in my situation.


ROB, WRITE DOWN MY NAME. IF YOU EVER READ ANOTHER POST FROM ME. YOUR INPUT
WILL NEVER BE DESIRED. JUST SAY THANK YOU AND MOVE ON.
 
I think Rob is referring to this sentence in your original post, David ...

--
Brendan Reynolds (MVP)

David said:
Well Rob,
I have been reading posts on this site for about a year now. And this is
by
far the worst. Even ignorant people realize that if you don't have
anything
nice to say, don't say it. Or in today's world, If you don't have
anything
to contribute, DON'T!

First of all, who are you? You know very little about the situation and
my
database structure. What is the purpose of your post. You offer no
advice,
just cheap shots. You are dead wrong, the purpose of C&P is not to LINK
two
tables together, but to allow the user to insert a large amount of data
into
a field from a source outside of the database. The TRIM will allow future
users who search for the project to find the project. Project "ABC" is
different that project " ABC". It is difficult for the user to visualyl
identify that there is a space before the project name when they enter the
project. So if they enter " ABC", and later search for project "ABC" it
will
say, no project found. The like "*" & [Project] & ""*" was not a good
option
in my situation.


ROB, WRITE DOWN MY NAME. IF YOU EVER READ ANOTHER POST FROM ME. YOUR
INPUT
WILL NEVER BE DESIRED. JUST SAY THANK YOU AND MOVE ON.


Rob Oldfield said:
You're using a text field that people feel the need to C&P for linking?
That is lousy database design that is going to leap up and bite you on
the
bum. You'd be better off rethinking your table structure.
 
Exactly right. Apologies for the misunderstanding.


Brendan Reynolds said:
I think Rob is referring to this sentence in your original post, David ...

--
Brendan Reynolds (MVP)

David said:
Well Rob,
I have been reading posts on this site for about a year now. And this is
by
far the worst. Even ignorant people realize that if you don't have
anything
nice to say, don't say it. Or in today's world, If you don't have
anything
to contribute, DON'T!

First of all, who are you? You know very little about the situation and
my
database structure. What is the purpose of your post. You offer no
advice,
just cheap shots. You are dead wrong, the purpose of C&P is not to LINK
two
tables together, but to allow the user to insert a large amount of data
into
a field from a source outside of the database. The TRIM will allow future
users who search for the project to find the project. Project "ABC" is
different that project " ABC". It is difficult for the user to visualyl
identify that there is a space before the project name when they enter the
project. So if they enter " ABC", and later search for project "ABC" it
will
say, no project found. The like "*" & [Project] & ""*" was not a good
option
in my situation.


ROB, WRITE DOWN MY NAME. IF YOU EVER READ ANOTHER POST FROM ME. YOUR
INPUT
WILL NEVER BE DESIRED. JUST SAY THANK YOU AND MOVE ON.


Rob Oldfield said:
You're using a text field that people feel the need to C&P for linking?
That is lousy database design that is going to leap up and bite you on
the
bum. You'd be better off rethinking your table structure.


Works very well. Thank you.

:

Private Sub Text0_AfterUpdate()

If Not IsNull(Me!Text0) Then
Me!Text0 = LTrim(Me!Text0)
End If

End Sub

Replace 'LTrim' with 'Trim' if you want to trim trailing spaces too.

--
Brendan Reynolds (MVP)


Access 2002 user,
I have a data entry form where users frequently use Copy and Paste
functionality to populate text boxes on the form.

Users are copying a space before the text, and since I use these
fields to
LINK or join to other tables/queries.... it's not workin out so
well.

How can I check if the first character or two is = blank and if it
is,
trim
those spaces out (Text field)?

Thank you
 
Back
Top