I am new with access database and our database having rounding issues can any one help me here is the Query. - Private Sub ComputeInvoice(ciArg As String)
-
If IsNull(Me.[CustomerID]) Then
-
MsgBox ("Customer ID required!")
-
Exit Sub
-
End If
-
Dim SUBTOTAL As Double
-
Dim MATERIALCOST As Double
-
Dim HOURSTOTAL As Double
-
Dim TAX As Double
-
Dim MyDB As Database, MyRS As Recordset
-
Set MyDB = DBEngine.Workspaces(0).Databases(0)
-
Set MyRS = MyDB.OpenRecordset("tblcustomers", dbOpenTable)
-
MyRS.Index = "CustomerID"
-
MyRS.Seek "=", Me![CustomerID]
-
Me![CustomerID] = MyRS![CustomerID]
-
Me!LABORRATE = MyRS![LABORRATE]
-
MyRS.Close
-
-
SUBTOTAL = 0
-
MATERIALCOST = 0
-
HOURSTOTAL = 0
-
'MsgBox Val(materialcost)
-
If Not IsNull(Me![MAT1]) Then MATERIALCOST = MATERIALCOST + Me!MAT1
-
If Not IsNull(Me![MAT2]) Then MATERIALCOST = MATERIALCOST + Me!MAT2
-
If Not IsNull(Me![MAT3]) Then MATERIALCOST = MATERIALCOST + Me!MAT3
-
If Not IsNull(Me![MAT4]) Then MATERIALCOST = MATERIALCOST + Me!MAT4
-
If Not IsNull(Me![MAT5]) Then MATERIALCOST = MATERIALCOST + Me!MAT5
-
If Not IsNull(Me![MAT6]) Then MATERIALCOST = MATERIALCOST + Me!MAT6
-
If Not IsNull(Me![MAT7]) Then MATERIALCOST = MATERIALCOST + Me!MAT7
-
If Not IsNull(Me![MAT8]) Then MATERIALCOST = MATERIALCOST + Me!MAT8
-
If Not IsNull(Me![MAT9]) Then MATERIALCOST = MATERIALCOST + Me!MAT9
-
If Not IsNull(Me![MAT10]) Then MATERIALCOST = MATERIALCOST + Me!MAT10
-
If Not IsNull(Me![MAT11]) Then MATERIALCOST = MATERIALCOST + Me!MAT11
-
If Not IsNull(Me![MAT12]) Then MATERIALCOST = MATERIALCOST + Me!MAT12
-
If Not IsNull(Me![MAT13]) Then MATERIALCOST = MATERIALCOST + Me!MAT13
-
If Not IsNull(Me![MAT14]) Then MATERIALCOST = MATERIALCOST + Me!MAT14
-
If Not IsNull(Me![MAT15]) Then MATERIALCOST = MATERIALCOST + Me!MAT15
-
If Not IsNull(Me![HOUR1]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR1
-
If Not IsNull(Me![HOUR2]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR2
-
If Not IsNull(Me![HOUR3]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR3
-
If Not IsNull(Me![HOUR4]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR4
-
If Not IsNull(Me![HOUR5]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR5
-
If Not IsNull(Me![HOUR6]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR6
-
If Not IsNull(Me![HOUR7]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR7
-
If Not IsNull(Me![HOUR8]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR8
-
If Not IsNull(Me![HOUR9]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR9
-
If Not IsNull(Me![HOUR10]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR10
-
If Not IsNull(Me![HOUR11]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR11
-
If Not IsNull(Me![HOUR12]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR12
-
If Not IsNull(Me![HOUR13]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR13
-
If Not IsNull(Me![HOUR14]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR14
-
If Not IsNull(Me![HOUR15]) Then HOURSTOTAL = HOURSTOTAL + Me!HOUR15
-
Me!totalmaterial = Round(MATERIALCOST, 2)
-
Me!totalhours = Round(HOURSTOTAL, 2)
-
-
Me!totalcost = Round(HOURSTOTAL * LABORRATE, 2)
-
SUBTOTAL = Round((HOURSTOTAL * LABORRATE), 2) + MATERIALCOST
-
If Me!TYPE = "LR" Then Me!totalhours = Round((HOURSTOTAL * 1.5), 2)
-
If Me!TYPE = "LR" Then Me!totalcost = Round((HOURSTOTAL * 73), 2)
-
-
If Me!TYPE = "LR" Then SUBTOTAL = Round((HOURSTOTAL * 73), 2) + MATERIALCOST
-
-
-
-
TAX = 0
-
Me!invoicetotal = SUBTOTAL + TAX
-
-
If ciArg = "C" Then
-
Exit Sub
Can any one tell me when i add to total why my total is wrong like one digit up or down.
4 1582
Hi portsamerica,
Perhaps you could tell us what language you are writing this in, as well as the database you are using. Also, give us a general sense of where the error is occurring. List any debugging methods you have tried, as well as your thoughts on their results.
this is MS ACCESS 2003 database and i never work on it.my boss want me to look in to that and fix the rounding issue.
NeoPa 32,556
Expert Mod 16PB
Please tell us which item is rounding incorrectly.
What type of field is used for the item?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Colin Steadman |
last post by:
My ASP page allows user to enter comments into a form. To avoid
errors I'm having to strip out double quotes before saving to the
database. Is there anyway to encode these so that I can store...
|
by: news |
last post by:
Well, I wrote my first PHP class today. Yeah!
But to get it to work, in each function within the class I have to
repeat the database connection lines, and that just seems redundant;
there has to...
|
by: Zachary Hilbun |
last post by:
The below is some test code to help me learn how to update a dataset.
It is supposed to read the value of UserCounter and write it back.
The UserCounter is being read correctly as 0, is 1 when...
|
by: Roger Cantillo |
last post by:
Hi,
I'm using oleDBConnection to connect to SQL server. I keep getting "SQL
Server does not exist" on Open event.
The code I'm using is the following
Dim objConn As New...
|
by: cj |
last post by:
Lets assume all calculations are done with decimal data types so things
are as precise as possible.
When it comes to the final rounding to cut a check to pay dividends for
example in VB rounding...
|
by: jdrott1 |
last post by:
i'm trying to round my currency string to end in 9. it's for a
pricing application.
this is the function i'm using to get the item in currency:
FormatCurrency(BoxCost, , , , TriState.True)
if...
|
by: md |
last post by:
Hi
Does any body know, how to round a double value with a specific number
of digits after the decimal points?
A function like this:
RoundMyDouble (double &value, short numberOfPrecisions)
...
|
by: John |
last post by:
Hi
Are there any RAD apps to speed up one-many db application development that
are worth considering?
Thanks
Regards
|
by: jacob navia |
last post by:
Hi
"How can I round a number to x decimal places" ?
This question keeps appearing. I would propose the following
solution
#include <float.h>
#include <math.h>
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |