Solved

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

Posted on 2011-03-01
8
556 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
 

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

The new Microsoft OS looks great, is easier than ever to upgrade to, it is even free.  So what's the catch?  If you don't change the privacy settings, Microsoft will, in accordance with the (EULA) you clicked okay to without reading, collect all the…
This article will show you how to use shortcut menus in the Access run-time environment.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

760 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now