Results 1 to 4 of 4
  1. #1
    SltPhx is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    41

    Hide the Access Background Window

    Hello all you superbrains!
    I am using Access 2010 and trying to hide the background access window, so that only my forms are visible to the end users.
    After researching, I found these VBA codes, but I always get an error. I am sure I am missing something. And I would like your help to find that out.

    I have changed all my forms & reports to Pop-up and Modal. This is the code that I use on OnLoad of the Main (first form):

    Private Sub Form_Load()
    Const SW_HIDE = 0
    Const SW_SHOWNORMAL = 1
    Const SW_SHOWMINIMIZED = 2
    Const SW_SHOWMAXIMIZED = 3
    Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
    Dim dwReturn As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
    ByVal nCmdShow As Long) As Long
    Public Function fAccessWindow(Optional Procedure As String, Optional SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
    If Procedure = "Hide" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    End If
    If Procedure = "Show" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
    If Procedure = "Minimize" Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
    End If
    If SwitchStatus = True Then
    If IsWindowVisible(hWndAccessApp) = 1 Then
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    Else
    dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
    End If
    If StatusCheck = True Then
    If IsWindowVisible(hWndAccessApp) = 0 Then
    fAccessWindow = False
    End If
    If IsWindowVisible(hWndAccessApp) = 1 Then


    fAccessWindow = True
    End If
    End If
    End Function

    End Sub



    When I open my the database- the mian window is still there and I get an error

    "The espression On Load you entered as the even property setting produced the following error: Only comments may appear after End Sub, End Function or End Property.
    *The expression may not result in the name of a macro, the name of a user-defined function, or [Even Procedure].
    *There may have been an error evaluating the function, event or macro.

    Can anybody tell me what is wrong? Do I have to change any thing in File-> Options?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    Private Sub Form_Load()
    Const SW_HIDE = 0
    Const SW_SHOWNORMAL = 1
    Const SW_SHOWMINIMIZED = 2
    Const SW_SHOWMAXIMIZED = 3
    Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
    Dim dwReturn As Long
    Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
    ByVal nCmdShow As Long) As Long
    Public Function fAccessWindow(Optional Procedure As String, Optional  SwitchStatus As Boolean, Optional StatusCheck As Boolean) As Boolean
    If Procedure = "Hide" Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
    End If
    If Procedure = "Show" Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
    End If
    If Procedure = "Minimize" Then
        dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMINIMIZED)
    End If
    If SwitchStatus = True Then
        If IsWindowVisible(hWndAccessApp) = 1 Then
            dwReturn = ShowWindow(Application.hWndAccessApp, SW_HIDE)
        Else
            dwReturn = ShowWindow(Application.hWndAccessApp, SW_SHOWMAXIMIZED)
        End If
    End If
    If StatusCheck = True Then
        If IsWindowVisible(hWndAccessApp) = 0 Then
            fAccessWindow = False
        End If
        If IsWindowVisible(hWndAccessApp) = 1 Then
            fAccessWindow = True
        End If
    End If
    End Function
    
    End Sub
    One thing is a Function routine cannot be nested within a Subroutine (or the other way).

    And I believe that the Private Declare Function should not be in a Sub/Function. It should be at the top of the page below the "Option Explicit" statement. That is the way I've seen them.

  3. #3
    SltPhx is offline Advanced Beginner
    Windows Vista Access 2010 32bit
    Join Date
    Jul 2011
    Posts
    41
    Thank you for being so prompt. I appreciate it. I am still getting the same error =>

    "The expression On Load you entered as the even property setting produced the following error: Only comments may appear after End Sub, End Function or End Property.
    *The expression may not result in the name of a macro, the name of a user-defined function, or [Even Procedure].
    *There may have been an error evaluating the function, event or macro.
    Show Help: This error occurs when an event has failed to run because the location of the logic for the event cannot be evaluated. For example, if the OnOpen property of a form is set to =[Field], this error occurs because a macro or event name is expected to run when the event occurs."

  4. #4
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    "Procedure" is a reserved word in Access and shouldn't be used as an object name.

    See http://allenbrowne.com/AppIssueBadWord.html

    Have you seen this site? http://access.mvps.org/access/api/api0019.htm

Please reply to this thread with any new information or opinions.

Similar Threads

  1. access query displaying in the background
    By buienxg in forum Programming
    Replies: 1
    Last Post: 11-21-2011, 10:21 AM
  2. Hide Access 2010 runtime window
    By cevatyildiz in forum Programming
    Replies: 4
    Last Post: 03-28-2011, 07:28 AM
  3. Hide database window in Access 2010
    By Kevin Johnston in forum Access
    Replies: 5
    Last Post: 09-23-2010, 09:44 AM
  4. How can I hide/unhide DB window with a single button?
    By aquaraider in forum Programming
    Replies: 2
    Last Post: 10-09-2009, 07:01 AM
  5. Hide the Database window
    By wasim_sono in forum Access
    Replies: 5
    Last Post: 02-02-2006, 06:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums