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!

Controlling for bad data entry in a string

Status
Not open for further replies.

jcrawford08

Technical User
Nov 19, 2008
71
US
Hi All,

CR XI, SQL Environment...

I have a text field, and in situations where less than 3 Chr(13)s have been entered, or the instance of ["/", ", "] is less than 3:

stringvar baddata;
local stringvar x:={RV_Practitioner_Office_TaxID.Comments};
local numbervar i;
local numbervar cntpar;
local numbervar cnt;
for i:=1 to len(x) do(if x in [chr(13)] then cntpar:=cntpar+1 else if x in [", ","/"] then cnt:=cnt+1);

if cntpar<>3 or cnt<3 then baddata:="Bad Data Entry" else
baddata:="";

baddata


The problem is, the counts aren't coming out right - I snagged the majority of this formula from thread767-1611310 - when I put the items into a formula by themselves and reference the counts I get 0....


any ideas?


Thanks

Not in word only, but in deed also... 1Jn3:18
 
stringvar baddata := "";
local stringvar x:={RV_Practitioner_Office_TaxID.Comments};
local numbervar i;
local numbervar cntpar;
local numbervar cnt;
for i:=1 to len(x) do(
if x = chr(13) then
cntpar:=cntpar+1;
if x = [", ","/"] then
cnt:=cnt+1
);
if cntpar<>3 or
cnt<3 then
baddata := "Bad Data Entry" else
baddata := "";
baddata

-LB
 
Unfortunately, that didn't work...

Still shows as "Bad Data Entry", even when I've made sure the data matches up... two instances of ", " and one instance of "/", and three instances of chr(13)... all entered properly, and yet it is still displaying 'bad data entry'....

here's the data from the field:

930 sw Abbey Street, Ste A
Newport, OR 97365
R111111/2356789
5pm

Not in word only, but in deed also... 1Jn3:18
 
When I tested it (below), it worked perfectly--if you run it as is, it returns nothing, but if you comment out one of the address lines, it returns the bad data notice:

stringvar baddata := "";
local stringvar x:= "930 sw Abbey Street, Ste A"+chr(13)+
"Newport, OR 97365"+chr(13)+
"R111111/2356789"+chr(13)+
"5pm";
local numbervar i;
local numbervar cntpar;
local numbervar cnt;
for i:=1 to len(x) do(
if x = chr(13) then
cntpar:=cntpar+1;
if x = [", ","/"] then
cnt:=cnt+1
);
if cntpar<>3 or
cnt<3 then
baddata := "Bad Data Entry" else
baddata := "";
baddata

...So I think you should paste in your version of my formula.

-LB
 
My sincere apologies :) all worked fine, I must've been too tired Friday - I missed the zeroing out of the string at the top and the the after the mention of x's.... all works well...


Thank you again for all your patience and help LB!

Not in word only, but in deed also... 1Jn3:18
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top