Results 1 to 9 of 9

Thread: Hide main Access window

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Question Hide main Access window

    I want to hide the main access window and just show my form, but I don't understand what I need form this code I found on the web to make it work??

    VB Code:
    1. Global Const SW_HIDE = 0
    2. Global Const SW_SHOWNORMAL = 1
    3. Global Const SW_SHOWMINIMIZED = 2
    4. Global Const SW_SHOWMAXIMIZED = 3
    5.  
    6.  
    7. Private Declare Function apiShowWindow Lib "user32" _
    8.     Alias "ShowWindow" (ByVal hwnd As Long, _
    9.           ByVal nCmdShow As Long) As Long
    10.  
    11. Function fSetAccessWindow(nCmdShow As Long)
    12. 'Usage Examples
    13. 'Maximize window:
    14. '       ?fSetAccessWindow(SW_SHOWMAXIMIZED)
    15. 'Minimize window:
    16. '       ?fSetAccessWindow(SW_SHOWMINIMIZED)
    17. 'Hide window:
    18. '       ?fSetAccessWindow(SW_HIDE)
    19. 'Normal window:
    20. '       ?fSetAccessWindow(SW_SHOWNORMAL)
    21. '
    22. Dim loX  As Long
    23. Dim loForm As Form
    24.     On Error Resume Next
    25.     Set loForm = Screen.ActiveForm
    26.     If Err <> 0 Then 'no Activeform
    27.       If nCmdShow = SW_HIDE Then
    28.         MsgBox "Cannot hide Access unless " _
    29.                     & "a form is on screen"
    30.       Else
    31.         loX = apiShowWindow(hWndAccessApp, nCmdShow)
    32.         Err.Clear
    33.       End If
    34.     Else
    35.         If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
    36.             MsgBox "Cannot minimize Access with " _
    37.                     & (loForm.Caption + " ") _
    38.                     & "form on screen"
    39.         ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
    40.             MsgBox "Cannot hide Access with " _
    41.                     & (loForm.Caption + " ") _
    42.                     & "form on screen"
    43.         Else
    44.             loX = apiShowWindow(hWndAccessApp, nCmdShow)
    45.         End If
    46.     End If
    47.     fSetAccessWindow = (loX <> 0)
    48. End Function

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Hide main Access window

    You should just be able to paste that code into a form/module in your Access project, then add the line of code below wherever you want to hide Access (this must be after at least one form is visible):

    Call fSetAccessWindow(SW_HIDE)

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Re: Hide main Access window

    Ok so I pasted it all into a module, then created a command button on my form to test it. Opened the form hit the cmd button and it says, Cannot hide Access with tblPSR on screen. Which tblPSR is the name of my form and it's on the screen. So what's up??

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Hide main Access window

    Well that message is shown if the following If is true:
    VB Code:
    1. ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
    For the first half, nCmdShow must equal SW_HIDE, as that is the operation that you are trying to perform.

    For the second half (the part that you can effectively change) the PopUp property of loForm (the active form) needs to be True in order for the If to fail, and thus hide the window. So, go into the property page of the form and change Popup to True (or possibly Yes).

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Re: Hide main Access window

    Great! But when I hit the cmd button it hides all of Access and the form too.

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Hide main Access window

    Ok, it seems that this code isn't quite what you want then.. and I'm not even sure that it would be possible, as the form you have created is a 'child' of the main Access window.

    I've tried to find previous examples on this site where this sort of thing has been done, these were the closest I could find:
    http://www.vbforums.com/showthread.php?t=353923
    http://www.vbforums.com/showthread.php?t=355443
    http://www.vbforums.com/showthread.php?t=346258
    http://www.vbforums.com/showthread.php?t=113426

  7. #7
    Fanatic Member dannymking's Avatar
    Join Date
    Jul 2005
    Location
    Darlington, North East UK
    Posts
    677

    Re: Hide main Access window

    You can also fool your user's into thinking it is something other than access..

    In the Tools, Startup option screen do the following

    Set an Application Icon for the database and an Application Title, untick the following:

    Allow Full Menus
    Allow Built In Toolbars
    Display Database Window
    Display Status Bar
    Allow Toolbar/Menu Changes
    Allow Default Shortcut Menus

    On top of this it is best to create your own customised menu bar with the options you want available and any toolbars that you want, you may also want to remove some of the built in options behind the forms, like record selectors, navigation buttons and dividing lines. Plus if you are allowing shortcut menu's on your forms then design one that you want and set this to each form's Shortcut Menu Bar.

    Then set a start-up form and your users will not see any reference to Access itself.

    You can even disable the Bypass Key (Shift) but you must be careful with that one.
    Last edited by dannymking; Oct 9th, 2005 at 05:38 AM.
    Danny

    Never Think Impossible

    If you find my answer helpful then please add to my reputation

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Location
    Long Island, NY.
    Posts
    353

    Re: Hide main Access window

    Here is what my screen looks like. I was under the impression that if you create the form as a pop-up then the code above will hide the Main access window with your current form still up???
    Attached Images Attached Images  

  9. #9
    Member
    Join Date
    Nov 2004
    Posts
    48

    Re: Hide main Access window

    Write an interface using VB and access the database that way

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width