kevlray
Registered User.
- Local time
- Yesterday, 16:49
- Joined
- Apr 5, 2010
- Messages
- 1,046
I got assigned to fix the code for a user. I thought I had an idea what I was doing but still getting an error.
So here is the original code.
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
fSetAccessWindow = (loX <> 0)
End Function
I commented out the Private Declare Function apiShowWindow....
and put in
#If Win64 Then
Declare PtrSafe Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As LongLong, ByVal nCmdShow As LongLong) As LongLong
#Else
Declare PtrSafe Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
#End If
but now I get a type mismatch for the loX = apiShowWindow(HWndAccessApp, nCmdShow)
I figure it is because nCmdShow is declare as Long for the function fSetAccessWindow, but I do not know how to fix it.
So here is the original code.
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
fSetAccessWindow = (loX <> 0)
End Function
I commented out the Private Declare Function apiShowWindow....
and put in
#If Win64 Then
Declare PtrSafe Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As LongLong, ByVal nCmdShow As LongLong) As LongLong
#Else
Declare PtrSafe Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
#End If
but now I get a type mismatch for the loX = apiShowWindow(HWndAccessApp, nCmdShow)
I figure it is because nCmdShow is declare as Long for the function fSetAccessWindow, but I do not know how to fix it.