Click here to Skip to main content
15,890,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing a query in VBA and i am having issues with the Len function:
Code:
SQL
sql = "Select [" + fld.name + "] "
                    sql = sql + "from [" + tbl.name + "] "
                    sql = sql + "Where len([" + fld.name + "]) <= '10'"


If I filter for a length less than 10 the process works and the query outputs all records whose length is less than 10. However if I use '10' or greater it gives me zero records? I tried using MS Access and it repeated the problem.

Seriously confused...
Posted

1 solution

Len should be returning a numeric value - so you should not be comapring against '10' but rather 10.
This line should look like
sql = sql + "Where len([" + fld.name + "]) <= 10"
 
Share this answer
 
Comments
ShawnSapp 26-May-11 13:39pm    
Thanks,
Abhinav S 26-May-11 13:41pm    
You are welcome.
Marc A. Brown 26-May-11 13:58pm    
Good catch!
Abhinav S 26-May-11 14:01pm    
Thanks.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900