While I was waiting I came up with this procedure, that for the most part,
solves my problem, but I'm a novice and would like to know if it is good or
bad programimg. I like that I don't have to guess what is coming up in the
text to deal with, except for a few, and that could be a plus.
'with var106 as text variable, following loop strips all punctuation, except
for ^_[ ]\ at least as far as I could find
var111 = Len(var106)
var114 = ""
Do Until var111 = 0
If Left(var106, 1) Like "[aA-zZ]" Then
var111 = Len(var106)
var113 = Left(var106, 1)
var114 = var114 & var113
var106 = Mid(var106, 2, var111)
Else:
var111 = Len(var106)
var106 = Mid(var106, 2, var111)
End If
Loop
var106 = var114 ' ends punctuation removal
fredg said:
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
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
(No private e-mails, please)
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])