473,372 Members | 898 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,372 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 1322
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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?

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.