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

Math is wrong...I know it's my fault, but I don't know how to fix it 1

Status
Not open for further replies.

LongFeiFengWu

Technical User
Nov 9, 2001
98
US
Here's the code for some math I need done on my page:

FOR i = 5 to objrec.fields.count - 1

IF objrec.fields(i).value > 0 THEN thecount = thecount + 1

fieldvalue=objrec.fields(i).value

AHTC = objrec("JANAHTC") + objrec("FEBAHTC") + objrec("MARAHTC") + objrec("APRAHTC") + objrec("MAYAHTC") + objrec("JUNAHTC") + objrec("JULAHTC") + objrec("AUGAHTC") + objrec("SEPAHTC") + objrec("OCTAHTC") + objrec("NOVAHTC") + objrec("DECAHTC")
AHTE = objrec("JANAHTE") + objrec("FEBAHTE") + objrec("MARAHTE") + objrec("APRAHTE") + objrec("MAYAHTE") + objrec("JUNAHTE") + objrec("JULAHTE") + objrec("AUGAHTE") + objrec("SEPAHTE") + objrec("OCTAHTE") + objrec("NOVAHTE") + objrec("DECAHTE")
AHTO = objrec("JANAHTO") + objrec("FEBAHTO") + objrec("MARAHTO") + objrec("APRAHTO") + objrec("MAYAHTO") + objrec("JUNAHTO") + objrec("JULAHTO") + objrec("AUGAHTO") + objrec("SEPAHTO") + objrec("OCTAHTO") + objrec("NOVAHTO") + objrec("DECAHTO")
CPH = objrec("JANCPH") + objrec("FEBCPH") + objrec("MARCPH") + objrec("APRCPH") + objrec("MAYCPH") + objrec("JUNCPH") + objrec("JULCPH") + objrec("AUGCPH") + objrec("SEPCPH") + objrec("OCTCPH") + objrec("NOVCPH") + objrec("DECCPH")
ATT = objrec("JANATT") + objrec("FEBATT") + objrec("MARATT") + objrec("APRATT") + objrec("MAYATT") + objrec("JUNATT") + objrec("JULATT") + objrec("AUGATT") + objrec("SEPATT") + objrec("OCTATT") + objrec("NOVATT") + objrec("DECATT")
TIPS = objrec("JANTIPS") + objrec("FEBTIPS") + objrec("MARTIPS") + objrec("APRTIPS") + objrec("MAYTIPS") + objrec("JUNTIPS") + objrec("JULTIPS") + objrec("AUGTIPS") + objrec("SEPTIPS") + objrec("OCTTIPS") + objrec("NOVTIPS") + objrec("DECTIPS")
OBS = objrec("JANOBS") + objrec("FEBOBS") + objrec("MAROBS") + objrec("APROBS") + objrec("MAYOBS") + objrec("JUNOBS") + objrec("JULOBS") + objrec("AUGOBS") + objrec("SEPOBS") + objrec("OCTOBS") + objrec("NOVOBS") + objrec("DECOBS")
REV = objrec("JANREV") + objrec("FEBREV") + objrec("MARREV") + objrec("APRREV") + objrec("MAYREV") + objrec("JUNREV") + objrec("JULREV") + objrec("AUGREV") + objrec("SEPREV") + objrec("OCTREV") + objrec("NOVREV") + objrec("DECREV")
MEET = objrec("JANMEET") + objrec("FEBMEET") + objrec("MARMEET") + objrec("APRMEET") + objrec("MAYMEET") + objrec("JUNMEET") + objrec("JULMEET") + objrec("AUGMEET") + objrec("SEPMEET") + objrec("OCTMEET") + objrec("NOVMEET") + objrec("DECMEET")
DEV = objrec("JANDEV") + objrec("FEBDEV") + objrec("MARDEV") + objrec("APRDEV") + objrec("MAYDEV") + objrec("JUNDEV") + objrec("JULDEV") + objrec("AUGDEV") + objrec("SEPDEV") + objrec("OCTDEV") + objrec("NOVDEV") + objrec("DECDEV")

YTDAHTC = formatDIV(AHTC,thecount,1)
YTDAHTE = formatDIV(AHTE,thecount,1)
YTDAHTO = formatDIV(AHTO,thecount,1)
YTDCPH = formatDIV(CPH,thecount,1)
YTDATT = formatDIV(ATT,thecount,1)
YTDTIPS = formatDIV(TIPS,thecount,1)
YTDOBS = formatDIV(OBS,thecount,1)
YTDREV = formatDIV(REV,thecount,1)
YTDMEET = formatDIV(MEET,thecount,1)
YTDDEV = formatDIV(DEV,thecount,1)

next

%>

What's happening is that the columns, as you may notice are JAN thru DEC with whatever the field data is. JANAHTC thru DECAHTC as an example. I did this for each data type in a single table. What I need to have happen is to have AHTC = JANAHTC thru DECAHTC and then YTDAHTC = formatDIV(AHTC,the count of JANAHTC thru DECAHTC where the value > 0 ,1). What I'm getting with my current script is the count of all columns in the table with values > 0 and that's messing up the math. Anyone have any ideas? Should I scrap this and start over?

"If nothing within you stays rigid, outward things will disclose themselves. Moving, be like water. Still, be like a mirror. Respond like an echo." ~ Bruce Lee
 
[lol]
"if i only had a brain" - scarecrow

<clip>formatnumber[/](<clip>

missed 3 letters there when i typed it for you

[thumbsup2]DreX
aKa - Robert
 
jeebus ... i really cant type today...

<clip>formatnumber(<clip>

[thumbsup2]DreX
aKa - Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top