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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for alpha numeric values in a field 3

Status
Not open for further replies.

micang

Technical User
Aug 9, 2006
626
US
Access 2003

Hi All,

I have a table in Access that a field with vehicle descriptions.

I would like to identify all records that have any chracters other than an alpha and \or numeric with in the description.

e.g.

Description
Ford 14 Saloon S-A
Mazda 3
Porsche 911 Turdo +


From the following, the 1st and last row would be identified, the middle row is fine.

I have tried [a-z][0-9], but I get a variety of results.

I thought maybe a function could be put together to achieve this?

Any help in the correct path will be appreciated.

Thank you.

Michael
 
try a function with a loop

Code:
public function AllText(strinput as string)
dim x as integer

isstring=true '(assume it is true for now) 
for x=1 to len(strinput)
if not mid(strinput,x,1) like "[a-z]" or mid(strinput,x,1) like "[A-Z]] then
 Alltext=false
 exit function
end if
Alltext=true

You may need to adjust to allow for nulls, etc.

SeeThru
Synergy Connections Ltd - Telemarketing Services

 
Hi SeeThru,

Thank you for your time.

I have tried this below - changed the or bit, gave an error.
Code:
Public Function AllText(strinput As String)
Dim x As Integer

'isstring = True '(assume it is true for now)
For x = 1 To Len(strinput)

If Not Mid(strinput, x, 1) Like "[a-z][A-Z]" Then ' or mid(strinput,x,1) like "[A-Z]] then

 AllText = False
 Exit Function
End If
AllText = True
Next
End Function

Unfortunatly, it does not return correct results - it returns them all as valid.

Michael
 

If Not Mid(strinput, x, 1) Like "[a-z][A-Z]" Then

You have an extra Then. Take it out. Must correct syntax errors first.
 
No need of a function at all:
Like "*[! 0-9A-Z]*"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV (and everyone else), Like "*[! 0-9A-Z]*" does indeed to the trick.

Much appreciated.

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top