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

formula blowing up in subreport 1

Status
Not open for further replies.

bitsmith2k

Programmer
Mar 5, 2003
34
0
0
CA
hey guys,

i've got a bit of a problem here.. dunno if i've maybe overlooked something in my code.. hopefully you can help.

my report works fine on its own. it gives me the the totals i'd expect. i've since added it as a subreport in one of our main reports.. for some strange reason it blows up giving me the error: the string is non-numeric.

this does it for the same set of parameters that i feed it when it's on its own..

the code for the formula that seems to be giving me the problems is below.

thanks

mike

Code:
whileprintingrecords;


stringvar ga;
numbervar finalg;

stringvar pa;
numbervar finalp;

if {tblMain_ItemTax.TaxesIncluded} = "Y" then
(
    ga := totext (( {tblMain_TransTickets.NetPrice} / {tblMain_TransTickets.NumOfPeople}) * 0.07);
    if tonumber (ga[length(ga) - 1]) = 5 and (tonumber (ga[length(ga) -2]) mod 2 = 0) then
       finalg := tonumber (ga[1 to length(ga) - 2]) * {tblMain_TransTickets.NumOfPeople}
    else        
        finalg := round (tonumber(ga), 2) * {tblMain_TransTickets.NumOfPeople};
)
else 
(
   ga := totext ({tblMain_TransTickets.NetPrice} * 0.07);
   if tonumber (ga[length(ga) - 1]) = 5 and (tonumber (ga[length(ga) -2]) mod 2 = 0) then
        finalg := tonumber (ga[1 to length(ga) - 2])
   else        
        finalg := round (tonumber(ga), 2);
);

if "PST" in {tblMain_TransTickets.ItemTax} then
(
    if {tblMain_ItemTax.TaxesIncluded} = "Y" then
    (
        pa := totext (( {tblMain_TransTickets.NetPrice} / {tblMain_TransTickets.NumOfPeople}) * 0.1);
        if tonumber (pa[length(pa) - 1]) = 5 and (tonumber (pa[length(pa) -2]) mod 2 = 0) then
            finalp := tonumber (pa[1 to length(pa) - 2]) * {tblMain_TransTickets.NumOfPeople}
        else        
            finalp := round (tonumber(pa), 2) * {tblMain_TransTickets.NumOfPeople};
    )
    else 
    (
        pa := totext ({tblMain_TransTickets.NetPrice} * 0.1);
        if tonumber (pa[length(pa) - 1]) = 5 and (tonumber (pa[length(pa) -2]) mod 2 = 0) then
            finalp := tonumber (pa[1 to length(pa) - 2])
        else        
            finalp := round (tonumber(pa), 2);
    );
)
else finalp := 0;
 
The tonumbers are probably getting you.

You can check this condition using the isnumeric function prior to executing the tonumber code, as in:

if isnumeric(ga) then...

-k

 
great thanks for the help... i realised that i didn't change the default number and currency to carry four decimal places in the new report.


mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top