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

Pulling Minimum Lengths

Swi

Programmer
Feb 4, 2002
1,977
US
Hi,

I have the below query. My thought was the part at the end would only select records that had a +4 zip code (12345-1234), however this does not seem to work. Any ideas?

Thanks.

Code:
"SELECT Min(Len([NAME])) AS [NAME], " & _
            "Min(Len([ADDR2])) As [ADDR2], Min(Len([ADDR1])) As [ADDR1], " & _
            "Min(Len([CITY ST ZIP])) As [CITY ST ZIP], Min(Len([Salutation])) As [Salutation] " & _
            "FROM [Test.csv] WHERE LEFT(RIGHT([CITY ST ZIP],5),1) = '-'"
 
You never said why you think the expression didn’t seem to work or provide examples.

Most of us recommend three separate fields for City, State, and Zip. Maybe you have no control over this.
 
I will give that a shot. After I posted I think I may have found the issue but had to leave for the day. I will check it Monday and report back. Thanks.
 
I think you have trailing spaces in the field, so the thought of having a - in the left 1 char of the rightmost 5 chars is wrong, you first need to trim off spaces (and other whitespace, if there may be tabs, for example, even if only accidentally).
 

Part and Inventory Search

Sponsor

Back
Top