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

delete contents of field for certain criteria

Status
Not open for further replies.

eboughey1008

Programmer
Jan 6, 2009
31
US

I can delete the contents of the zip field if with a !isdigt() command but I need a little more now.

I need to keep canadian records which have an alpha numeric zip so I can't make my zip field numeric.

I need a command that allows me to delete the contents if there is a character in the field and it's less than 6 characters.

ie:

repl all zip with "" for (????)$zip and len(trim(zip)) < 6

do I need to create a variable with all the letters in the alphabet??? I hope not. Seems like I'd have to look for those characters at all 6 characters....

notallowed = "A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z"
repl all zip with "" for notallowed$substr(zip,2,1) and len(trim(zip)) < 6
 
REPLACE ALL zip WITH CHRTRAN(zip,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','!!!!!!!!!!!!!!!!!!!!!!!!!!') for len(alltrim(zip)) < 6 **you can replace '!' with any character that will never be in a zip.

replace all zip with "" for '!' $ zip



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top