String function to replace characters

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

Guest

I have an input text box where the user can enter text. On the after update
I guess of that field, I want to go through what they entered and replace
certain characters with a space. For instance replace all apostrophy's with
spaces, so Steve's becomes Steve s

Is there a string function that will do this in ACCESS?

Thanks,
Steve
 
Surprising enough, it's called Replace! <g>

Me.MyTextBox = Replace(Me.MyTextBox, "'", " ")

(BTW, it only exists in Access 2000 and newer. If you're using Access 97 or
earlier, post back)
 
Thank you! I was in ACCESS help, searched String, string function, instr,
just didn't see the Replace. Sounds like what I am looking for!

Thanks
 
Hi, Steve.
Is there a string function that will do this in ACCESS?

Yes. For Access 2000 and newer versions. It's the Replace( ) function.
Syntax:

Replace(expression, find, replace[, start[, count[, compare]]])

Example:

Me!txtName.Value = Replace(Me!txtName.Value, "'", " ")

.... where txtName is the name of the text box.

If you are using Access 97 or earlier, it's not a built-in function.
There's a user-defined function you may use, so please post back if you need
it.

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.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Back
Top