473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Mathmatic record problems...

Hi,

I have the following piece of code which is ment to do a
couple of calculations for me, however for some reason
tmprs("disc") returns some strange results.

If I enter a value of 10 for tmprs("disc") it is fine but
if I enter a second value for tmprs("disc") it doubles my
value. E.G. if I enter 20 the result is 2020

Why and how do I fix it???

An example of response.write statement might look like
this:

0
10
2020

Please help!
Thanks

...:: CODE ::..

if not (tmprs.eof and tmprs.bof) then
tmprs.movefirst
totalcost = 0
totaldisc = 0
grandtotal = 0
while not tmprs.eof
response.write (totaldisc)
response.write ("<BR>")
response.write (tmprs("disc"))
totalcost = totalcost + (tmprs("Quantity") * tmprs
("UnitCost"))
totaldisc = (totalcost / 100 * (totaldisc + tmprs
("disc")))
tmprs.movenext
wend
totaltax = ((totalcost-totaldisc)/100) * TaxAmount
grandtotal = (totalcost + totaltax + numchk(rs
("ShipCost")) + numchk(rs("SurCharge"))) - totaldisc
'error correction
On Error Resume Next
usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
(numchk(rs("ShipCost")/exrate)) + (numchk(rs
("SurCharge")/exrate))) - (totaldisc/exrate)
If Err.Number <> 0 Then

Else
Jul 19 '05 #1
1 1323
Look up Cint(), Clng(), CDbl() and CSng() at
http://www.devguru.com/Technologies/...functions.html

You should convert your input to a known numeric type.

Mike
"MyaTiX" <an*******@discussions.microsoft.com> wrote in message
news:04****************************@phx.gbl...
Hi,

I have the following piece of code which is ment to do a
couple of calculations for me, however for some reason
tmprs("disc") returns some strange results.

If I enter a value of 10 for tmprs("disc") it is fine but
if I enter a second value for tmprs("disc") it doubles my
value. E.G. if I enter 20 the result is 2020

Why and how do I fix it???

An example of response.write statement might look like
this:

0
10
2020

Please help!
Thanks

..:: CODE ::..

if not (tmprs.eof and tmprs.bof) then
tmprs.movefirst
totalcost = 0
totaldisc = 0
grandtotal = 0
while not tmprs.eof
response.write (totaldisc)
response.write ("<BR>")
response.write (tmprs("disc"))
totalcost = totalcost + (tmprs("Quantity") * tmprs
("UnitCost"))
totaldisc = (totalcost / 100 * (totaldisc + tmprs
("disc")))
tmprs.movenext
wend
totaltax = ((totalcost-totaldisc)/100) * TaxAmount
grandtotal = (totalcost + totaltax + numchk(rs
("ShipCost")) + numchk(rs("SurCharge"))) - totaldisc
'error correction
On Error Resume Next
usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
(numchk(rs("ShipCost")/exrate)) + (numchk(rs
("SurCharge")/exrate))) - (totaldisc/exrate)
If Err.Number <> 0 Then

Else

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Uwe Range | last post by:
Hi to all, I am displaying a list of records in a subform which is embedded in a popup main form (in order to ensure that users close the form when leaving it). It seems to be impossible to...
20
by: MS | last post by:
Access 97 I want to requery the data being displayed on a form, then I want to return to the record I was in. Why doesn't this code work? Private Sub CmdRefsh_Click()
6
by: Not Me | last post by:
Hi, I have a stored procedure as a recordsource for a form, taking a parameter from another form, it displays records that are already present without any problems. I had to add a resync...
5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
12
by: swingingming | last post by:
Hi, in the NorthWind sample database, when clicking on the next navigation button on the new order record with nothing on the subform (order details), we got an order with nothing ordered. How can...
9
by: al | last post by:
Hi I need to automaticaly print new records/reports in an Access database to a labelprinter. Can this be done? The records are added with asp code. The Labelprinter is a Brother QL-550 ...
1
by: Brian | last post by:
Hey all - I have a windows form (using VB) in which I display basic information about a person, all of which is housed (for now) in a single Access table, which I'll call "tblPerson". I would...
1
by: Wes Brooks | last post by:
Hello expert, Please help me with the following problems. I have spent ages to resolve them but no luck. I have two forms. (1) "Document Reception Input Form" is the main form. The search...
3
by: rn5a | last post by:
In my local computer, date has been set in this format - dd/MM/yyyy. When I insert records in a MS-Access DB table using ASP.NET, then the records get inserted in the Access DB table exactly in the...
7
by: Evanescent | last post by:
Hi guys, as the title suggests, I'm facing some problems with the report. I have a form (createInvoiceForm) whereby the user can enter the invoice's details and then click on the Add New Record...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.