我有一个函数,我使用时删除除字母数字字符的一切。只需创建一个查询,并在查询中使用该函数试图修改的任何字段。运行速度比查找和替换要快得多。
Public Function AlphaNumeric(inputStr As String)
Dim ascVal As Integer, originalStr As String, newStr As String, counter As Integer, trimStr As String
On Error GoTo Err_Stuff
' send to error message handler
If inputStr = "" Then Exit Function
' if nothing there quit
trimStr = Trim(inputStr)
' trim out spaces
newStr = ""
' initiate string to return
For counter = 1 To Len(trimStr)
' iterate over length of string
ascVal = Asc(Mid$(trimStr, counter, 1))
' find ascii vale of string
Select Case ascVal
Case 48 To 57, 65 To 90, 97 To 122
' if value in case then acceptable to keep
newStr = newStr & Chr(ascVal)
' add new value to existing new string
End Select
Next counter
' move to next character
AlphaNumeric = newStr
' return new completed string
Exit Function
Err_Stuff:
' handler for errors
MsgBox Err.Number & " " & Err.Description
End Function
只是注意到代码的链接,看起来类似于我的。猜猜这只是另一种选择。
向我们展示失败追加查询的SQL视图,并向我们提供您遇到的错误的更详细描述。 – HansUp 2010-03-22 18:03:51
对于第二个@HansUp,现在您已经发现连字符不是问题,您需要提供错误消息。 – 2010-03-22 19:43:18
这个字段的数据类型是什么? – Nick 2010-03-23 10:18:10