Displaying an Access GUI without the default Acces

2019-01-11 21:36发布

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).

5条回答
何必那么认真
2楼-- · 2019-01-11 21:47

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.
查看更多
欢心
3楼-- · 2019-01-11 21:55

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.

查看更多
神经病院院长
4楼-- · 2019-01-11 21:58

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....

查看更多
我命由我不由天
5楼-- · 2019-01-11 21:59

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.

查看更多
老娘就宠你
6楼-- · 2019-01-11 22:07

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).

查看更多
登录 后发表回答