runtime error 6 overflow (1 Viewer)

bbouwer

Registered User.
Local time
Today, 18:54
Joined
Dec 23, 2009
Messages
17
Hi,

I need to calculate some variables:

Dim intSubmap1 As Integer
Dim intSubmap2 As Integer
intDocID = 123

intSubmap1 = Int(intDocID / (256 * 256))


After running the last line i get a runtime error 6:eek:verflow.

I ran it also in VB6,no problems.

What's wrong in this ?

Thanks !
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:54
Joined
Aug 30, 2003
Messages
36,125
Just for chuckles, try making them both Long instead of Integer. Also, you declare a variable you don't use, and use a variable you haven't declared (though I doubt either contributes to your error).
 

Steve R.

Retired
Local time
Today, 12:54
Joined
Jul 5, 2006
Messages
4,684
My quick response is that you are dividing by an extremely large number (256*256) which raises two issues, one you don't have a real integer and second you are essentially dividing by zero.

I would suggest using decimal numbers and converting the resultant to an integer as a last step.
 
Last edited:

MarkK

bit cruncher
Local time
Today, 09:54
Joined
Mar 17, 2004
Messages
8,181
This is a data type problem. 256 is an Integer and when you do Integer math VBA expects an Integer result, but the biggest Integer in VBA is 32767. 256 * 256 is 65536. Overflow.
Since you've hard coded the 256 * 256 you could replace that with 65536, or you can append '&' to a number which coerces it to a Long data type. If you multiply Long * Long VBA expects a Long ...
Code:
Debug.Print TypeName(256), TypeName(256[COLOR="DarkRed"]&[/COLOR])
intSubmap1 = Int(intDocID / (256[COLOR="DarkRed"]&[/COLOR] * 256[COLOR="DarkRed"]&[/COLOR]))
 

Poppa Smurf

Registered User.
Local time
Tomorrow, 02:54
Joined
Mar 21, 2008
Messages
448
When the error message is displayed select Help and it will give you the solution.

You will need to use the following, as the result is 1.8768310546875E-03
Also you must force one of your integers to LONG

Dim intSubmap1 As Double
intDocID = 123
intSubmap1 = intDocID / (CLng(256) * 256)
 

bbouwer

Registered User.
Local time
Today, 18:54
Joined
Dec 23, 2009
Messages
17
combobox wizard

Hi,

I have 2 different databases,in which i want to create a combobox through the combobox wizard option.In the first database after creating a combobox on the form through the wizard i have 2 options,in the second database,i have 3 options,see attachments.Can anyone tell me where this extra option is coming from ? I need it to use it.

Thanks !
 

Attachments

  • combo1.GIF
    combo1.GIF
    12.9 KB · Views: 468
  • combo2.GIF
    combo2.GIF
    17.2 KB · Views: 428

ajetrumpet

Banned
Local time
Today, 11:54
Joined
Jun 22, 2007
Messages
5,638
Hi,

I need to calculate some variables:

Dim intSubmap1 As Integer
Dim intSubmap2 As Integer
intDocID = 123

intSubmap1 = Int(intDocID / (256 * 256))


After running the last line i get a runtime error 6:eek:verflow.

I ran it also in VB6,no problems.

What's wrong in this ?

Thanks !

convert it to double just to be safe. CDBL(). at that rate, you probably would have no possibly of overflowing the variable type. doubles are VERY VERY long.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:54
Joined
Aug 30, 2003
Messages
36,125
The extra option should show up when the form being worked on is bound to a table.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:54
Joined
Aug 30, 2003
Messages
36,125
That means the form's Record Source property is a table.
 

bbouwer

Registered User.
Local time
Today, 18:54
Joined
Dec 23, 2009
Messages
17
Thanks guys,for all your help,2 problems solved,thanks !!!!
 

bbouwer

Registered User.
Local time
Today, 18:54
Joined
Dec 23, 2009
Messages
17
opening tiff files

Hi guys,

Another thing which confuses me.

I have a large access db,containing records with documentsnames,folder and amount of pages,all somewhere else stored docs are tiff files with extension .001,in case of one connected tiff, .001,.002 ,incase of more connected tiff files.

When a user selects a record, these files have to be shown,the microsoft office image viewer is available on all the pc's.

How can i solve this matter,i only have vba code,other external software is not allowed (banking environment).

Can i convert these files into one multipage tiff,or because adobe is also available,into a multipage pdf file ?

Or just,show one after the other,sometimes there are more then 50 files connected.

Also,in case of showing one after the other,how can i show a file called 123.001 in a viewer,which only opens with .tiff files ?

I hope you guys can help me,

Bert.
 

bbouwer

Registered User.
Local time
Today, 18:54
Joined
Dec 23, 2009
Messages
17
Re: opening tiff files

Hi guys,

Another thing which confuses me.

I have a large access db,containing records with documentsnames,folder and amount of pages,all somewhere else stored docs are tiff files with extension .001,in case of one connected tiff, .001,.002 ,incase of more connected tiff files.

When a user selects a record, these files have to be shown,the microsoft office image viewer is available on all the pc's.

How can i solve this matter,i only have vba code,other external software is not allowed (banking environment).

Can i convert these files into one multipage tiff,or because adobe is also available,into a multipage pdf file ?

Or just,show one after the other,sometimes there are more then 50 files connected.

Also,in case of showing one after the other,how can i show a file called 123.001 in a viewer,which only opens with .tiff files ?

I hope you guys can help me,

Bert.

Guys ? Please Help !
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 09:54
Joined
Aug 30, 2003
Messages
36,125
You can use FollowHyperlink to open a tiff file in the default program. I don't have experience with Adobe, so not sure about putting them into one file.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 17:54
Joined
Sep 12, 2006
Messages
15,654
on the original thread

intSubmap1 = Int(intDocID / (256 * 256))

if docid is 123, then this will return 0, wont it anyway

ie relatively small number didivided by large number - you will either get 0 or 1 for the answer. - so are you expecting this or is there a logic error anyway?
 

Users who are viewing this thread

Top Bottom