vba 显示没有默认访问框架的访问 GUI
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1291341/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Displaying an Access GUI without the default Access frame
提问by Justin
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).
有没有办法告诉访问只显示表单/报告而不显示访问窗口本身(访问表单填充在其中的“外壳”窗口)。
回答by Albert D. Kallal
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
实际上,这里的大多数帖子都相当陈旧,并且基于旧版本的 Access。自 2007 年以来,您只需点击几下鼠标和一行代码即可隐藏界面。在文件-选项->当前数据库下
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:
结果是这样的:
So all these wild solutions with API, whacks of code etc. is not required unless one is looking to increase world poverty.
因此,除非人们希望增加世界贫困,否则不需要所有这些带有 API、重击代码等的疯狂解决方案。
Just a few mouse clicks and one line of code to hide the Access UI been possible for the last 3 versions (2007 onwards).
在过去的 3 个版本(2007 年以后)中,只需点击几下鼠标和一行代码即可隐藏 Access UI。
回答by JP Alioto
Yes, you can. See "Setting Startup Options" from Basics for Building Microsoft Office Access 2003 Runtime-Based Solutions.
是的你可以。请参阅《构建基于运行时的 Microsoft Office Access 2003 解决方案的基础》中的“设置启动选项” 。
You can use the Startup dialog box to specify the following:
- Whether or not the Database window should be displayed on startup.
您可以使用“启动”对话框指定以下内容:
- 是否应在启动时显示数据库窗口。
回答by Philippe Grondier
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.
为此,我利用了一段由一些聪明人编写并在网上可用的代码(我认为它最初是由 Terry Kreft 编写的?)并引用了一些 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.
屏幕会“闪烁”一点,主窗口会短暂出现,然后消失。我的焦点窗口将单独显示。
回答by Robert Harvey
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.
如果您创建一个 MDE 并在 Access Runtime 下运行它,它将执行您的程序,并去除(大部分,如果不是全部)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.
这是设计使然。Access Runtime 旨在允许您分发应用程序的副本,同时剥夺用户的常规 Access 陷阱。
回答by Kevin LaBranche
No. Access is a classic Multiple Document Interface (MDI) where all the child windows are inside a parent window.
不是。Access 是一个经典的多文档界面 ( MDI),其中所有子窗口都在一个父窗口内。
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.
但是,Access 确实有很多方法可以更改父窗口菜单和工具栏。您可以创建自己的菜单和工具栏布局,其中仅包含您想要的内容。谷歌在 Access 中创建菜单栏和工具栏,它应该指向正确的方向。
EDIT:
编辑:
JP nailed it.... My brain forgot that little nugget....
JP 搞定了……我的大脑忘记了那个小金块……