Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Setup / Configuration / August 2004

Tip: Looking for answers? Try searching our database.

Access window

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ronny - 30 Aug 2004 23:03 GMT
Anyone knows why I cannot get this to work:
(http://www.mvps.org/access/api/api0019.htm)

I get an error saying : cannot hide Access unless a form is on screen_
-----------------------------------
     Manipulate Access Window
    Author(s)
     Dev Ashish

     (Q)    How do I maximize or minimize the main Access Window from code?

     (A)    Pass one of the declared constants to the function
fSetAccessWindow.

       This same function can also be used to completely hide Access window
and just show your form on the desktop.  Make the form popup and from it's
Open Event, call the fSetAccessWindow function with SW_HIDE as the argument.

       Warning:    If you're hiding the main Access window,  make sure your
error handlers are good.  Because with the window hidden, if an error is
raised, pressing "End" on the Error window will NOT make Access window
visible and you will be left with just the form open.   A recommended method
is to make a call to fSetAccessWindow with SW_SHOWNORMAL from your error
handlers.
           If,  for some reason, the Access window does not show itself,
then you can always close the mdb from the Task List, available in Win 95
with Control-Alt-Delete (once) and under NT, by right clicking on the
Taskbar and selecting Task Manager, by selecting the mdb and clicking End
Task.

'************ Code Start **********
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
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)
'Usage Examples
'Maximize window:
'       ?fSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
'       ?fSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
'       ?fSetAccessWindow(SW_HIDE)
'Normal window:
'       ?fSetAccessWindow(SW_SHOWNORMAL)
'
Dim loX  As Long
Dim loForm As Form
   On Error Resume Next
   Set loForm = Screen.ActiveForm
   If Err <> 0 Then 'no Activeform
     If nCmdShow = SW_HIDE Then
       MsgBox "Cannot hide Access unless " _
                   & "a form is on screen"
     Else
       loX = apiShowWindow(hWndAccessApp, nCmdShow)
       Err.Clear
     End If
   Else
       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
   End If
   fSetAccessWindow = (loX <> 0)
End Function

'************ Code End **********

Ronny
Jeff Conrad - 31 Aug 2004 00:16 GMT
Hi,

I believe I have seen this before.
The problem is a timing issue as Access does not "see' the form yet.

Just to make sure everything else is OK, please follow these steps:

- Copy/paste all the code to a new standard module if you haven't already.
- Compile the code, save the module and name it modHideAccessWindow.
- Open the code behind the form and copy this code into the Form's Open event:

Private Sub Form_Open(Cancel As Integer)
On Error GoTo ErrorPoint

   Me.Visible = True
   fSetAccessWindow (SW_HIDE)

ExitPoint:
   Exit Sub

ErrorPoint:
   MsgBox "The following error has occurred:" _
   & vbNewLine & "Error Number: " & Err.Number _
   & vbNewLine & "Error Description: " & Err.Description _
   , vbExclamation, "Unexpected Error"
   Resume ExitPoint

End Sub

- Compile the code, save the form, and then test.

The Me.Visible = True line made sure Access "saw" the form before hiding it.
Hopefully that should solve the problem for you.

Signature

Jeff Conrad
Access Junkie
Bend, Oregon

> Anyone knows why I cannot get this to work:
> (http://www.mvps.org/access/api/api0019.htm)
>
> I get an error saying : cannot hide Access unless a form is on screen_

<<Code Snipped>>

> Ronny
- 31 Aug 2004 10:28 GMT
ok, I just added
   Me.Visible = True
   fSetAccessWindow (SW_HIDE)
to the forms open event... and it works great...

ronny
>-----Original Message-----
>Hi,
[quoted text clipped - 41 lines]
>
>.
Jeff Conrad - 31 Aug 2004 16:54 GMT
Excellent, good to hear.

Signature

Jeff Conrad
Access Junkie
Bend, Oregon

> ok, I just added
>     Me.Visible = True
[quoted text clipped - 56 lines]
> >
> >.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.