Re: Preserve trailing spaces in a textbox

Tech-Archive recommends: Fix windows errors by optimizing your registry



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


.



Relevant Pages

  • Re: OT: President-elect a JMS fan?
    ... "The American President". ... Especially the bit at the end, where the President rips Senator Bob ... character, and although I have not been willing to engage in his ...
    (rec.arts.sf.tv.babylon5.moderated)
  • Re: Chapter pacing...
    ... Character A is in ch. ... > Let's call them Abe and Bob. ... > Chapter 8 is mostly exposition and character development, ... certainly have no preference as a reader if the writer does a good job. ...
    (rec.arts.sf.composition)
  • Re: Friday and Job vs the Brain Eater
    ... I mean, it's a concert CD, and you can hear the audience laughing ... I have this problem with about half of the MTM Bob Newhart Show ... character does not compare in my mind to Emily. ...
    (rec.arts.sf.written)
  • Re: Chapter pacing...
    ... Character A is in ch. ... Let's call them Abe and Bob. ... If I have the reader see Bob die first, without Abe's knowledge, then there might be additional poignancy to the character development and the revelation of Bob's importance. ... We'd also roll out the exposition earlier, which might be a good thing. ...
    (rec.arts.sf.composition)
  • Re: Hyphen is being replaced by question mark
    ... Word does not register the question mark and skips right ... standard place for a hyphen in Unicode. ... character to the Clipboard, open Ctrl-H again, and press Ctrl-V to put ...
    (microsoft.public.word.docmanagement)