The following syntax should help you to search for those irritating characters such as double quotes (") within a field or string.
If InStr(1, field or string, character to search for, vbTextCompare) Then
.... code that you want to run if character found
End If
EG.
This searches for a " in the field called address1 on the active form. Try to use the ascii characters when searching for single characters. Please refer to DougP's FAQ to find a list of ASCII characters (1a in the FAQs). I have not tried to look for larger strings so I am not sure if it would work for them.
If InStr(1, Me!Address1, Chr(34), vbTextCompare) Then
MsgBox "invalid character found"
varContinue = False
End If
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.