Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding ascii values within strings or fields

Access Howto:

Finding ascii values within strings or fields

by  mdav2  Posted    (Edited  )
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
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top