Solved

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

Posted on 2011-03-01
8
558 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
My experience with Windows 10 over a one year period and suggestions for smooth operation
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

919 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