Re: Preserve trailing spaces in a textbox
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Thu, 2 Nov 2006 16:27:49 +0800
Yes, but don't forget that there might be other characters at the end of a
word also: period, question mark, exclamation mark, dash, carriage return,
brackets, ...
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Fred Boer" <fredboer1@xxxxxxxxxxxxxxx> wrote in message
news:Oh3MAGj$GHA.3560@xxxxxxxxxxxxxxxxxxxxxxx
Hello Allen!
Thanks for the suggestion; I think I see how that would work, and will be
able to implement your solution. You are right about the issue with the
search term being at the end of a field, though... I hadn't thought of
that! Hmmm.... I suppose I could do something like: WHERE Author is LIKE
"Bob " OR Right(Author,Len(me.txtKeyword))= Me.txtKeyword...
Cheers!
Fred
"Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx> wrote in message
news:%23YBwevi$GHA.3396@xxxxxxxxxxxxxxxxxxxxxxx
Hi Fred
You would need some kind of flag to indicate if the final character was a
space.
Use the Change event of the control to examine its Text property, and set
a module-level boolean variable if the right-most character is a space.
In the AfterUpdate event of the control, append a space to its value if
the flag is true. The trailing space should stay there if assigned
programmatically like that.
A difficulty might be that if "Bob" is the last word in the field,
searching for "Bob " will not match it.
"Fred Boer" <fredboer1@xxxxxxxxxxxxxxx> wrote in message
news:OjBRvZh$GHA.3560@xxxxxxxxxxxxxxxxxxxxxxx
Hello:
I use data entered in a textbox to generate a SQL statement. I am aware
that
Access trims the trailing spaces from the data in the textbox. Is there
some
way to preserve these spaces? For example, suppose I want the search to
find
instances of "Bob" but not "Bobby", and I enter "Bob " into the textbox
(note the trailing space...).
Thanks!
Fred Boer
Here is some of the code this would work with (fncQuoted deals with
embedded
quotes)...
If Len(Me.txtKeyword) > 0 Then
sWHERE = " OR Author Like " & fncQuoted("*" & txtKeyword & "*") & _
" OR Title Like " & fncQuoted("*" & txtKeyword & "*") & " OR
Subject
Like " _
& fncQuoted("*" & txtKeyword & "*") & " Or Series Like " &
fncQuoted("*" & _
txtKeyword & "*") & " Or ISBN Like " & fncQuoted("*" & _
txtKeyword & "*")
End If
.
- Follow-Ups:
- Re: Preserve trailing spaces in a textbox
- From: Fred Boer
- Re: Preserve trailing spaces in a textbox
- References:
- Preserve trailing spaces in a textbox
- From: Fred Boer
- Re: Preserve trailing spaces in a textbox
- From: Allen Browne
- Re: Preserve trailing spaces in a textbox
- From: Fred Boer
- Preserve trailing spaces in a textbox
- Prev by Date: Re: File Summary Comment
- Next by Date: Re: AutoNumber question - MySQL for Access Forms
- Previous by thread: Re: Preserve trailing spaces in a textbox
- Next by thread: Re: Preserve trailing spaces in a textbox
- Index(es):
Relevant Pages
|