Saturday, December 26, 2009

How do you query only strings without numbers in access?

Is there a way to query a large group of strings to pull out the ones that do not have ANY numbers in the string?





Either with a SQL statement or in the design view.How do you query only strings without numbers in access?
In MS Access, try





Not Like ';*[123456789]*';How do you query only strings without numbers in access?
It would actually be more beneficial to create a small public function to parse the variable into it and return a true/false on codition it does or does not hold numerical data.





Public Function won(a)


Dim b As Integer


Dim d As String


Dim e As String


won = ';FALSE'; 'assume no numbers


For pos = 1 To Len(a)


d = Mid(a, pos, 1)


If d = ';1'; Or d = ';2'; Or d = ';3'; Or d = ';4'; Or d = ';5'; Or d = ';6'; Or d = ';7'; Or d = ';8'; Or d = ';9'; Or d = ';0'; Then e = ';TRUE'; 'found a number


Next pos


If e = ';TRUE'; Then won = ';TRUE'; 'we found a number


End Function





call won in your query like you would any other agument passing the variable or field you want to check.





I did this in fast so it's not elligent and I did it in notepad so check the syntax but it's the right syntax for Access VBA.





Doug
to avoid only numerics


select * from table1 where col1 not like '%[0-9]%'


to avoid alphs


select * from table1 where col1 not like '%[a-z]%'
Try this





select * from %26lt;table name%26gt; where %26lt;column name%26gt; not like '%1%2%3%4%5%6%7%8%9%0%'

No comments:

Post a Comment