Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2006, 01:07 AM
Registered User
 
Join Date: Jan 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to hiruni Send a message via MSN to hiruni
Default regarding Overflow of variable

hi all,
Im using a integer inside a loop for adding a value via a access database table. bt when i run it i get a added value, if there is few records at the table..if more records it give a error named "overflow"
so i think my integer memory is not enough..pls help me for tht. gv me a idea. thanx..


Dim total As Integer
Dim nn3tmp As Integer
Dim nn3 As String

'opening database and get its values to recSLT3 record set
If recSLT3.RecordCount >= 1 Then
        recSLT3.MoveFirst
Do While Not recSLT3.EOF
        nn3tmp = 0

      If IsNull(recSLT3.Fields("InvNo").Value) = False Then
                nn3 = recSLT3.Fields("Amount").Value

            row_num = row_num + 1

            nn3tmp = CInt(nn3)
            total = total + nn3tmp

        End If
        recSLT3.MoveNext
        Loop
    MsgBox total

End If

 
Old February 20th, 2006, 11:39 AM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try changing the type of nn3tmp to Float, I believe that's where the overflow is occuring (as I doubt you have more than 2,147,483,648 (top bound of Int data type) rows in the table).

 
Old February 25th, 2006, 10:56 AM
Authorized User
 
Join Date: Jan 2006
Posts: 35
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually I believe the limit of an Integer is 65535. Try changing to Long instead.

HTH RuralGuy (RG for short) acXP WinXP Pro
 
Old February 27th, 2006, 02:05 PM
Friend of Wrox
 
Join Date: Dec 2005
Posts: 142
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You're right, I took that number from an Access help page and not VBA like I should have. Thought it seemed kind of ridiculous for an int size.

 
Old February 27th, 2006, 02:17 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Not too rediculous. 2,147,483,647 is actually the max value of a .NET Framework 32-bit integer (System.Int32).

Bob






Similar Threads
Thread Thread Starter Forum Replies Last Post
ListBox - overflow possible? snufse ASP.NET 2.0 Basics 0 July 25th, 2008 09:50 AM
Overflow grstad Classic ASP Databases 18 December 14th, 2006 10:06 AM
Buffer Overflow rekha_jsr Oracle 3 February 3rd, 2005 08:11 PM
can anybody tell why i am getting overflow error tulsi15 SQL Server 2000 1 December 15th, 2004 07:58 AM
integer overflow partaola Beginning VB 6 2 March 17th, 2004 09:01 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.