?
Solved

Overflow Error on Calculation

Posted on 2008-06-15
17
Medium Priority
?
570 Views
Last Modified: 2011-10-19
Morning all,

Trying to calculate the wieight on a punch in Microsoft Access (form) in order to calculate the transport charge.

I'm getting an overflow on the following line of code. Can anyone help me overcome this?

w_calc = 3.14159265 * (Me.ShankDiameter / 10) ^ 2 * Me.OverallLength * 7.8 / 10 * 4 * 1000

shankdiameter = 4
overalllength = 80

Thanks
Sean

0
Comment
Question by:SeanNij
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 4
  • +1
17 Comments
 
LVL 46

Expert Comment

by:tbsgadi
ID: 21791146
Hi SeanNij,

What Data_Type are w_calc ,shankdiameter & overalllength ? (integer,single etc)


Gary
0
 
LVL 1

Author Comment

by:SeanNij
ID: 21791184
w_calc is long
shankdiameter is single
overlength is single
0
 
LVL 46

Accepted Solution

by:
tbsgadi earned 1200 total points
ID: 21791211
try w_calc = CLNG(3.14159265 * (Me.ShankDiameter / 10) ^ 2 * Me.OverallLength * 7.8 / 10 * 4 * 1000)
0
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 1

Author Comment

by:SeanNij
ID: 21791444
nope - same error
0
 
LVL 17

Assisted Solution

by:Natchiket
Natchiket earned 400 total points
ID: 21791636
hmmm looks like maybe the 2 * Me.OverallLength * 7.8 / 10 * 4 * 1000 is getting multiplied together before the power is applied giving a large exponential whereas presumably it's (shankdiameter/2) squared.
try

3.14159265 * ((Me.ShankDiameter / 10) ^ 2) * Me.OverallLength * 7.8 / 10 * 4 * 1000)
0
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 400 total points
ID: 21791737
w-calc is ?long?
Are you intentionally trying to lose the decimal part?

But I can't reproduce the problem in A2003.
All I'm doing is  this...

Private Sub Command4_Click()
Dim wcalc As Long
wcalc = 3.14159265 * (Me.Shankdiameter / 10) ^ 2 * Me.OverallLength * 7.8 / 10 * 4 * 1000
MsgBox wcalc
End Sub

msgbox shows...125463
0
 
LVL 1

Author Comment

by:SeanNij
ID: 21791879
Me.WeightPP = 3.14159265 * (Me.ShankDiameter / 10) ^ 2 * Me.OverallLength * 7.8 / (10 * 4 * 1000)
0
 
LVL 77

Expert Comment

by:peter57r
ID: 21792090
That works for me as well.

Go into the immediate pane and try:

?3.14159265 * (4 / 10) ^ 2 *80 * 7.8 / (10 * 4 * 1000)
0
 
LVL 1

Author Comment

by:SeanNij
ID: 21792324
RunTime Error '6'
Overflow i use immediate window
0
 
LVL 77

Expert Comment

by:peter57r
ID: 21792381
How peculiar...see attached

You are definitely using Access 2003?


Doc6.doc
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 21792438
Check that you don't have any missing references
0
 
LVL 1

Author Comment

by:SeanNij
ID: 21792474
brand new database
started from scratch yesterday on it.

what i did was uninstall office service pack 3 yesterday, cuase since i installed it my Access keeps crashing in weird places.

since uninstalling been fine....except for this error now....
0
 
LVL 1

Author Comment

by:SeanNij
ID: 21792478
hmmm

Me.WeightPP = 3.14159265 * (Me.ShankDiameter / 10) ^ 2 * Me.OverallLength * 7.8 / (10 * 4 * CLng(1000))

works....

WTF!!!!!!!!!!!!!
0
 
LVL 77

Expert Comment

by:peter57r
ID: 21792507
That might be an explanation.  I never moved to SP3 because of all the problems reported as soon as it was issued.
So my examples are all on sp2.


0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 21792582
You should install the hotfix for SP3
http://support.microsoft.com/kb/945674
0
 
LVL 1

Author Closing Comment

by:SeanNij
ID: 31467473
Splitting points for all the input - but the Clng got me working!
Thanks!
0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 21819587
Glad you got it working!
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question