473,915 Members | 4,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("Quantit y") * tmprs
("UnitCost") )
totaldisc = (totalcost / 100 * (totaldisc + tmprs
("disc")))
tmprs.movenext
wend
totaltax = ((totalcost-totaldisc)/100) * TaxAmount
grandtotal = (totalcost + totaltax + numchk(rs
("ShipCost") ) + numchk(rs("SurC harge"))) - totaldisc
'error correction
On Error Resume Next
usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
(numchk(rs("Shi pCost")/exrate)) + (numchk(rs
("SurCharge" )/exrate))) - (totaldisc/exrate)
If Err.Number <> 0 Then

Else
Jul 19 '05 #1
1 1334
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*******@disc ussions.microso ft.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("Quantit y") * tmprs
("UnitCost") )
totaldisc = (totalcost / 100 * (totaldisc + tmprs
("disc")))
tmprs.movenext
wend
totaltax = ((totalcost-totaldisc)/100) * TaxAmount
grandtotal = (totalcost + totaltax + numchk(rs
("ShipCost") ) + numchk(rs("SurC harge"))) - totaldisc
'error correction
On Error Resume Next
usgrandtotal = ((totalcost/exrate) + (totaltax/exrate) +
(numchk(rs("Shi pCost")/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
3984
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 delete a record in this subform. When I switched modal off and tried to delete a record from the list, I deleted a record on another form (below the popup form).
20
10700
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
3663
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 command to allow edits, but it works ok for now. The problem is when creating new records. If I open the form with datamode acFormAdd, I get the blank record fine, I can populate the fields ok. but when I come to close the record, I get the error
5
3357
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 I'm adding a customer. The Customer fields are mostly foreign keys that refer to primary keys in other tables, left join instead of junction tables at this point. So, when I want to add a customer record, I also need to add records to the other...
12
12992
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 we prevent this from happening? Thanks. ming
9
7953
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 Best Regards Anders Lorentzen
1
1192
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 like to select a set of records and display one at a time in text boxes with the following buttons: Next - Moves to next record Previous - Moves to previous record
1
1936
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 field Document ID is unbound combo box. The table is Documents. (2) "Document Reception Subform" is the sub form in tabular form. The linked field is DocID. The table is DocumentReception.
3
3226
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 same format as what has been set in my local machine. For e.g. if today is 21st February 2007 & the time is 10:45:32 AM, then this record gets inserted in the Access DB table as 21/02/2007 10:45:32 AM But when I try to insert the same...
7
2275
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 button (btnAddRecord). The data will be saved into the table (invoiceTable) and the user will be brought to the print preview of the report (invoice), showing the record which he has just added. In the createInvoiceForm, there is a combobox...
0
9883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9734
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4779
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4346
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3370
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.