Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2011-03-01
8
Medium Priority
?
575 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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