Thank you for the article and I understand the reason why this is happening with the change of 32 bit to 64. However, I do not know how to code. What part do I need to copy over? Some of the code in my program shows red (It is underlined below), is this
what needs to be replaced?
'Team Pro Solutions - www.t-p-s.co.uk
'
' Ken Getz and Michael Kaplan.
Option Compare Database
Option Explicit
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
(ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'-------------------------------------------------------------------------------------------------------------------
' Declarations
'
' These function names were puzzled out by using DUMPBIN /exports
' with VBA332.DLL and then puzzling out parameter names and types
' through a lot of trial and error and over 100 IPFs in MSACCESS.EXE
' and VBA332.DLL.
'
' These parameters may not be named properly but seem to be correct in
' light of the function names and what each parameter does.
'
' EbGetExecutingProj: Gives you a handle to the current VBA project
' TipGetFunctionId: Gives you a function ID given a function name
' TipGetLpfnOfFunctionId: Gives you a pointer a function given its function ID
'
'-------------------------------------------------------------------------------------------------------------------
Private Declare Function GetCurrentVbaProject _
Lib "vba332.dll" Alias "EbGetExecutingProj" _
(hProject As Long) As Long
Private Declare Function GetFuncID _
Lib "vba332.dll" Alias "TipGetFunctionId" _
(ByVal hProject As Long, ByVal strFunctionName As String, _
ByRef strFunctionId As String) As Long
Private Declare Function GetAddr _
Lib "vba332.dll" Alias "TipGetLpfnOfFunctionId" _
(ByVal hProject As Long, ByVal strFunctionId As String, _
ByRef lpfn As Long) As Long
'-------------------------------------------------------------------------------------------------------------------
' AddrOf
'
' Returns a function pointer of a VBA public function given its name. This function
' gives similar functionality to VBA as VB5 has with the AddressOf param type.
'
' NOTE: This function only seems to work if the proc you are trying to get a pointer
' to is in the current project. This makes sense, since we are using a function
' named EbGetExecutingProj.
'-------------------------------------------------------------------------------------------------------------------
Public Function AddrOf(strFuncName As String) As Long
Dim hProject As Long
Dim lngResult As Long
Dim strID As String
Dim lpfn As Long
Dim strFuncNameUnicode As String
Const NO_ERROR = 0
' The function name must be in Unicode, so convert it.
strFuncNameUnicode = StrConv(strFuncName, vbUnicode)
' Get the current VBA project
' The results of GetCurrentVBAProject seemed inconsistent, in our tests,
' so now we just check the project handle when the function returns.
Call GetCurrentVbaProject(hProject)
' Make sure we got a project handle... we always should, but you never know!
If hProject <> 0 Then
' Get the VBA function ID (whatever that is!)
lngResult = GetFuncID( _
hProject, strFuncNameUnicode, strID)
' We have to check this because we GPF if we try to get a function pointer
' of a non-existent function.
If lngResult = NO_ERROR Then
' Get the function pointer.
lngResult = GetAddr(hProject, strID, lpfn)
If lngResult = NO_ERROR Then
AddrOf = lpfn
End If
End If
End If
End Function
' From Dev Ashish's site.
'http://www.mvps.org/access/api/api0031.htm
'Warnings:
'(1) AddressOf is COMPLETELY UNSUPPORTED by Microsoft in Office 97
' environment. Use it at your own risk!!
'(2) Entering debug mode is not recommended as it is likely to
' cause problems (GPFs etc.).
'(3) Make sure you backup your work and save before running any such code.
' Using this technique adds another level of instability since
' there are so many different ways to set up things wrong.
' Once you get it to work properly, everything should be ok.
'(4) Make sure you enter a On Error Resume Next at the top of
' any callback function. This is done to ensure that any errors within a callback function are not propagated back to its caller.
'(5) Be careful of ByVal or ByRef when passing arguments to the function.
' If you don't get this right, nothing's going to work.
Public Function GetVersion()
Dim mintAccessVer As Integer
mintAccessVer = CInt(SysCmd(acSysCmdAccessVer))
If mintAccessVer = 9 Then ' Access 2000 ONLY
'lpPrevWndProc = SetWindowLong( _
' mhWndMDIClient, _
' GWL_WNDPROC, _
' AddressOf modMDIClient.WndProc)
ElseIf mintAccessVer = 8 Then ' Access 97 ONLY
' You will obviously need Michael Kaplan's and
' Ken Getz's AddrOf function in Access 97
'lpPrevWndProc = apiSetWindowLong( _
mhWndMDIClient, _
GWL_WNDPROC, _
AddrOf("WndProc"))
End If
End Function