Displaying an Access GUI without the default Access frame
Asked Answered
W

5

5

Is there a way to tell access to only display the forms/reports without displaying the access window itself (the "shell" window that the access forms populate inside of).

Wunderlich answered 18/8, 2009 at 1:20 Comment(0)
P
6

To do so, I take advantage of a piece of code written by some clever guys and available on the net (I think it was originally written by Terry Kreft?) and referring to some windows API.

I have first this:

Declare Function apiShowWindow Lib "user32" _
          Alias "ShowWindow" (ByVal hwnd As Long, _
          ByVal nCmdShow As Long) As Long

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3

and that

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 this form on screen:" & (loForm.Caption + " ")
       Else
           If nCmdShow = SW_HIDE And loForm.PopUp <> True Then
               MsgBox "Cannot hide Access with this form on screen:" & (loForm.Caption + " ")
           Else
               loX = apiShowWindow(hWndAccessApp, nCmdShow)
           End If
       End If
   End If
   fSetAccessWindow = (loX <> 0)

End Function

When starting my program, I will then call the function this way

'function is called by autoexec Macro'
...
fSetAccessWindow (SW_HIDE)
...
DoCmd.OpenForm my_Startup_Form
Forms(my_Startup_Form).Controls(my_Active_Control).SetFocus

The screen will 'flicker' a little bit, and the main window will appear briefly, then disappear. My focussed window will then be displayed alone.

Psychopath answered 18/8, 2009 at 9:56 Comment(4)
Does this still work in Access 2007? Any chance of a link to your source so I can get some more info on it?Matthaus
You really should include the URL of your source when you're using someone else's code. The URL for this is: mvps.org/access/api/api0019.htm , which is easily enough found by Googling the name of the function.Preset
Thanks David. I was planning to do that but I got caught by something uuuuuuurgeeeeeent (according to others!)Psychopath
A. , I guess it still woks in Access 2007, as it is related to Windows, not OfficePsychopath
O
16

Actually, most of the posts here are rather old and based on much older versions of Access. Since 2007 you can hide the interface with just a few mouse clicks and ONE LINE of code. Under file-Options->current database

Choose tabbed documents, choose hide document tabs. Un-check show navigation pane and also if you want to display the status bar.

Then in your startup form on load place this one line of code:

DoCmd.ShowToolbar "Ribbon", acToolbarNo

The result is this:

enter image description here So all these wild solutions with API, whacks of code etc. is not required unless one is looking to increase world poverty.

Just a few mouse clicks and one line of code to hide the Access UI been possible for the last 3 versions (2007 onwards).

Occlusive answered 8/7, 2014 at 18:8 Comment(1)
Maybe I missed something, but it seems Access 2016 still shows an entirely empty background window. Can you confirm this still works?Cinelli
A
9

Yes, you can. See "Setting Startup Options" from Basics for Building Microsoft Office Access 2003 Runtime-Based Solutions.

You can use the Startup dialog box to specify the following:

  • Whether or not the Database window should be displayed on startup.
Ashleyashli answered 18/8, 2009 at 1:36 Comment(2)
+1 I was trying to remember the exact setting. It's been awhile.Stichous
Ah... I had completely spaced that! :)Applicable
P
6

To do so, I take advantage of a piece of code written by some clever guys and available on the net (I think it was originally written by Terry Kreft?) and referring to some windows API.

I have first this:

Declare Function apiShowWindow Lib "user32" _
          Alias "ShowWindow" (ByVal hwnd As Long, _
          ByVal nCmdShow As Long) As Long

Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3

and that

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 this form on screen:" & (loForm.Caption + " ")
       Else
           If nCmdShow = SW_HIDE And loForm.PopUp <> True Then
               MsgBox "Cannot hide Access with this form on screen:" & (loForm.Caption + " ")
           Else
               loX = apiShowWindow(hWndAccessApp, nCmdShow)
           End If
       End If
   End If
   fSetAccessWindow = (loX <> 0)

End Function

When starting my program, I will then call the function this way

'function is called by autoexec Macro'
...
fSetAccessWindow (SW_HIDE)
...
DoCmd.OpenForm my_Startup_Form
Forms(my_Startup_Form).Controls(my_Active_Control).SetFocus

The screen will 'flicker' a little bit, and the main window will appear briefly, then disappear. My focussed window will then be displayed alone.

Psychopath answered 18/8, 2009 at 9:56 Comment(4)
Does this still work in Access 2007? Any chance of a link to your source so I can get some more info on it?Matthaus
You really should include the URL of your source when you're using someone else's code. The URL for this is: mvps.org/access/api/api0019.htm , which is easily enough found by Googling the name of the function.Preset
Thanks David. I was planning to do that but I got caught by something uuuuuuurgeeeeeent (according to others!)Psychopath
A. , I guess it still woks in Access 2007, as it is related to Windows, not OfficePsychopath
S
2

If you create an MDE and run it under the Access Runtime, it will execute your program stripped of (most, if not all of) the Access GUI.

This is by design. The Access Runtime is intended to allow you to distribute a copy of your application, while depriving your users of the regular Access trappings.

Stichous answered 18/8, 2009 at 1:29 Comment(4)
Even with an MDE you still have the parent window BUT the MDE does give you some extra's in it that make it very worthwhile.Applicable
Good suggestion on the Access Runtime. It will strip it down even more. :)Applicable
Note that there are all kinds of things you should know before deplying an app using the runtime. Such as ensuring you have a startup macro or form, the right mouse click menu no longer works, and you propably want to create your own abbreviated toolbar menus. See See my Microsoft Access ODE or MOD Runtime Installation Troubles Tips page at granite.ab.ca/access/runtime.htm.Geraud
Doesn't the right click continue to work when you've defined shortcut menus for your objects?Preset
A
1

No. Access is a classic Multiple Document Interface (MDI) where all the child windows are inside a parent window.

However, Access does have a lot of ways you can change the Parent Window Menu's and Toolbars. You can create your own menu and toolbar layouts that only have what you want in them. Google creating menu bars and toolbars in Access and it should point you in the right direction.

EDIT:

JP nailed it.... My brain forgot that little nugget....

Applicable answered 18/8, 2009 at 1:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.