hide access form and report

patatrac

Registered User.
Local time
Yesterday, 22:01
Joined
Jan 17, 2010
Messages
46
hi for all i add this code in a module and for form work fine no hide access, but no work for report
Code:
Option Compare Database
Option Explicit

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
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

Function rfSetAccessWindow(nCmdShow As Long)
Dim loX As Long
Dim nResult As Long
Dim hWnd As Long
loX = apiShowWindow(hWndAccessApp, nCmdShow)
rfSetAccessWindow = (loX <> 0)
End Function
anyone help me thanks
 
Not sure what you are trying to accomplish but there are easier methods for showing/hiding forms and reports. In any event the code you have only works for the active form. See changes in red.

Code:
Dim loX As Long
[COLOR=red]Dim loReport as Report[/COLOR]
On Error Resume Next
[COLOR=red]Set loReport = Screen.ActiveReport[/COLOR]
If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If

Other method for accompishing this would be as follows:

Code:
dim loForm as form
set loForm = Screen.ActiveForm
loForm.visible = false
 
Personally, I found trying to do all of this was a big pain in the backside and not worth the aggravation just to pretend that this wasn't written in Access. I quickly gave it up and have not gone back. That would be my suggested path to you as well.
 

Users who are viewing this thread

Back
Top Bottom