Thread: text control
View Single Post
  #5  
Old April 24th, 2004, 05:27 PM
fredg
external usenet poster
 
Posts: n/a
Default text control

On Sat, 24 Apr 2004 11:50:01 -0400, John Thomas wrote:

Thanks, I've seen that replace mentioned before, but must after office 97,
which is what I use and is not avaiable to me.

I have been playing in msword with find/replace and notice that if I use a
wildcard search like [aA-zZ], it will only select text and bypass
punctuation. Do you know of a way I could use that method, maybe in a do
loop to evalute a variable, stripping it of punctuation.

thanks john

"Douglas J. Steele" wrote in message
...
There's nothing built into Access to do this that I'm aware of.

To do it manually, use the Replace statement multiple times.

strText = Replace(strText, ".", "")
strText = Replace(strText, ", ", "")
strText = Replace(strText, ":", "")

etc.

or

strText = Replace(Replace(Replace(strText, ".", ""), ",", ""), ":", "")

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(No private e-mails, please)



"John Thomas" wrote in message
...
Is there a way to Remove all punctuation from a text string, without
identifying each type of punctuation, if not what is the best way to do

it
with the text as a variable.

Thanks John






In Access 97 you need to write your own User Defined Function.
The following will remove the following characters from a string:
! : ; ? . ,
Add to, or subtract from, the code as wanted.

Place this function in a module:

Function RemovePunctuation(StringIn As String) As String

Dim strNew As String
Dim intX As Integer
Dim intY As Integer
For intX = 1 To Len(StringIn)
intY = Asc(Mid(StringIn, intX))
If intY = 33 Or intY = 44 Or intY = 46 Or intY = 58 Or intY = 59
Or intY = 63 Then
Else
strNew = strNew & Chr(intY)
End If
Next intX
RemovePunctuation = strNew

End Function
===========

You can call it from a query:
Exp:RemovePunctuation([FieldName])


--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.