On Mon, 1 Mar 2010 12:08:01 -0800,
(E-Mail Removed)
<(E-Mail Removed)> wrote:
>Private Sub company_BeforeUpdate(Cancel as Integer)
> Dim Badlist As Variant
>Dim i As Integer
> Dim strIn As String
> strIn = Me!textboxname
> Badlist = Array("<", ">", "?", "/", "\")
> For i = 0 to Ubound(Badlist) - 1
> If InStr(strIn, Badlist(i)) > 0 Then
> strIn = Replace(strIn, Badlist(i), "("<", ">", "?", "/", "\")") '
>replace with a null string
> End If
> Next i
>Me!company = strIn
>End Sub
Well, that isn't what I suggested. What I suggested would work fine -
replacing the current element of the Badlist array with an empty string "".
You changed it and now it won't work.
The text "replace with a null string" is after a ' character, which makes it a
comment in the VBA code. The comment is of course optional and can be omitted.
Replace that line with
strIn = Replace(strIn, Badlist(i), "")
What the code will do is loop through all the elements in the Badlist array -
using i as a subscript to check elements 0, 1, 2 and so on; it wil then
replace that character with an empty string "", so a text string
3<5
will be converted to
35
--
John W. Vinson [MVP]