Solved

Run-time error '6' Overflow  error needing to be debugged

Posted on 2011-03-01
8
562 Views
Last Modified: 2012-05-11
In API utilities in Access 97  ( Iv'e used 97 because it's about as close to the Access Version 2 the old database is written in as I can get before converting to Access 2003 then 2007)the old database has converted but because 16bit  and 32 bit call are different I have adjusted as many as I can find ( eg integer to Long; User to User32; Kernel to Kernel32 ; etc ) but on loading the database in Access97 the Runtime error comes up and on debugging the yellow identifying line goes straight to the " wu_SetMenuChecked " If ..then line . I'm missing out on something here.
'------------------------------------------------------------------------
' FUNCTION    : wu_SetMenuChecked
'
' PURPOSE     : Sets the checkmark next to a menu item on or off.
'
' ARGUMENTS   : iMenu% - The index of the drop down menu
'               iItem% - The index of the item on the menu
'                           Both of these arguments are zero based.
'               fChecked% - True to show the checkmark, false otherwise.
'------------------------------------------------------------------------
Function wu_SetMenuChecked(iMenu%, iItem%, fChecked%) As Integer

    ' If the current form is Zoomed, account for the system menu.

    If (wu_IsZoomed(Screen.ActiveForm.hwnd)) Then
    iMenu% = iMenu% + 1
    End If

    hMainMenu% = wu_GetMenu(wu_GetAccessHwnd())
    hMenu% = wu_GetSubMenu(hMainMenu%, iMenu%)
    If (fChecked%) Then
        fuFlags% = WU_MF_BYPOSITION Or WU_MF_CHECKED
    Else
        fuFlags% = WU_MF_BYPOSITION Or WU_MF_UNCHECKED
    End If
    F% = wu_CheckMenuItem(hMenu%, iItem%, fuFlags%)
    wu_DrawMenuBar wu_GetAccessHwnd()
    wu_SetMenuChecked = F%

End Function

Get over this hurdle and I might find another this is puzzling me.
0
Comment
Question by:kinerang
  • 5
  • 3
8 Comments
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 35014525
The % symbol placed after a variable name declares that variable to be a VBA Integer (16-bit).  The range of VBA's Integer data type is -32768 to 32767.

Since I am not privy to how you are setting the variables, I would suggest that you do one of two things:

1) change your type declaration character from a percent (% = Integer) to an ampersand (& = Long).  By doing this, the range the variable can hold is WAY big! :)

2) drop the type declaration characters from your variables and explicitly declare the types ... something like this example for your procedure header...

Function wu_SetMenuChecked(lngMenu As Long, lngItem As Long, fChecked As Long) As Long
0
 

Author Comment

by:kinerang
ID: 35016007
datAdrenaline hang in there with me it would seem that the runtime error 6 has been solved and now I've a Type mismatch error 13 and picks up the line in yellow [  cch& = wu_GetClassName(hwnd, stBuff, cchMax)  ]

'------------------------------------------------------------------------
' FUNCTION    : wu_StWindowClass
'
' PURPOSE     : A simple cover function to the Windows API call.
'------------------------------------------------------------------------
Function wu_StWindowClass(hwnd As Long ) As String
    Const cchMax = 255
    Dim stBuff As String * cchMax
    cch& = wu_GetClassName(hwnd, stBuff, cchMax)
    If (hwnd& = 0) Then
        wu_StWindowClass = ""
    Else
        wu_StWindowClass = (Left$(stBuff, cch&))
    End If
End Function

The failed action of the AutoExec relates to the Condition True when runcode is actioned relevant to the Argument [ wu_SetMenuChecked(1,0,TRUE) ]

I am actually attempting to help a friend move this old database written for him years ago into current format because he wants to continue using this now that he's moved to a new computer with W7 because the old 'faithful' with W98 is gradually causing more intermittent issues I appreciate you other comments as it seems to have fixed my other concern first raised. There may be others lurking  but here goes again.
0
 
LVL 11

Accepted Solution

by:
datAdrenaline earned 500 total points
ID: 35017363
>> cch& = wu_GetClassName(hwnd, stBuff, cchMax) <<

you have defined cch& as a Long via the type declaration character of '&'.  It seems as though wu_GetClassName(hwnd, stBuff, cchMax) is returning a String, which can not be written to a Long.  So cch should be declared as a string.  The type declaration character for a string variable is '$'

So you can do something like this:
cch$ = wu_GetClassName(hwnd, stBuff, cchMax)

But ... I should let you know that programming with type declaration characters is no longer prevalent.  It is much more standard to explicitly declare your variables, like this:

Dim cch As String
cch = wu_GetClassName(hwnd, stBuff, cchMax)

It makes your code much easier to read.

----

Regardless of your approach, I hope this information has helped you out!
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:kinerang
ID: 35023057
Your  help has been fantastic I'm inclined to somehow reallocate points upwards or repost separately this  next part that has indicated a compile error  By Ref argument type mismatch  in the following.
where the yellow highlight picks up th line [ Function wu_GetAccessHwnd() As Long ]

'------------------------------------------------------------------------
' FUNCTION    : wu_GetAccessHwnd()
'
' PURPOSE     : Returns a handle the the Access window.
'------------------------------------------------------------------------

    hwnd% = wu_GetActiveWindow()
    While ((wu_StWindowClass(hwnd%) <> WU_WC_ACCESS) And (hwnd% <> 0))
        hwnd% = wu_GetParent(hwnd%)
    Wend
    wu_GetAccessHwnd = hwnd%
End Function






[ I might say that relatively simple databases I have done for others  about six or seven years ago have been using Access 2003 and it's the differences between the the older version plus my rustiness that leads me here so thanks.]
0
 

Author Closing Comment

by:kinerang
ID: 35032036
need to resubmit a related question in fairness to solution provider to enable greater number of points
0
 
LVL 11

Expert Comment

by:datAdrenaline
ID: 35034079
>> Your  help has been fantastic  <<

I am glad the information was helpful! ... now ... on to find your related question! ... :)
0
 

Author Comment

by:kinerang
ID: 35034795
I resubmitted this as a related question and have one response but am more than interested in what you suggest and where I should dp it.
How do I fix a compile error ( By Ref argument type mismatch) in an Access 2.0 conversion to newer 32bit version

In the database I am trying to convert from access version 2  it has now has indicated a compile error  By Ref argument type mismatch  in the following.
where the yellow highlight picks up th line [ Function wu_GetAccessHwnd() As Long ]

'------------------------------------------------------------------------
' FUNCTION    : wu_GetAccessHwnd()
'
' PURPOSE     : Returns a handle the the Access window.
'------------------------------------------------------------------------
Function wu_GetAccessHwnd() As Long
    hwnd& = wu_GetActiveWindow()
    While ((wu_StWindowClass(hwnd&) <> WU_WC_ACCESS) And (hwnd& <> 0))
        hwnd% = wu_GetParent(hwnd&)
    Wend
    wu_GetAccessHwnd = hwnd&
End Function

[ I might say that relatively simple databases I have done for others  about six or seven years ago have been using Access 2003 and it's the differences between the the older version plus my rustiness that leads me here so thanks.]
0
 

Author Comment

by:kinerang
ID: 35042969
Whilst the problem existing befoer seems well and truly fixed I'd like to clarify why the next statement showed up.  -  a compile error ( By Ref argument type mismatch) in an Access 2.0 conversion to newer 32bit version along where  yellow highlight picks up th line [ Function wu_GetAccessHwnd() As Long ]
 and focus on ( hwnd&) after StWindowClass  in line  While ((wu_StWindowClass(hwnd&) <> WU_WC_ACCESS) And (hwnd& <> 0))
        hwnd% = wu_GetParent(hwnd&)
Paul

That's also why I decided to resubmit as a new points question.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

773 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