在启动我的MS Access 2013数据库时,我只需要它来显示启动表单而不是其他任何内容。期望的结果将如下所示。背景是我的桌面。
所需:
然而,当我打开数据库时,表格将打开整个屏幕。
以下VBA代码在启动表单加载时运行,并且最初可以运行,但如果我最小化窗口,我可以再次看到背景。
Option Compare Database
Option Explicit
Global Const SW_HIDE = 0
Global Const SW_SHOWNORMAL = 1
Global Const SW_SHOWMINIMIZED = 2
Global Const SW_SHOWMAXIMIZED = 3
Private Declare Function apiShowWindow Lib "user32" _
Alias "ShowWindow" (ByVal hWnd As Long, _
ByVal nCmdShow As Long) As Long
Function fSetAccessWindow(nCmdShow As Long)
Dim loX As Long
Dim loForm As Form
On Error Resume Next
Set loForm = Screen.ActiveForm
If Err <> 0 Then
loX = apiShowWindow(hWndAccessApp, nCmdShow)
Err.Clear
End If
If nCmdShow = SW_SHOWMINIMIZED And loForm.Modal = True Then
MsgBox "Cannot minimize Access with " _
& (loForm.Caption + " ") _
& "form on screen"
ElseIf nCmdShow = SW_HIDE And loForm.PopUp <> True Then
MsgBox "Cannot hide Access with " _
& (loForm.Caption + " ") _
& "form on screen"
Else
loX = apiShowWindow(hWndAccessApp, nCmdShow)
End If
fSetAccessWindow = (loX <> 0)
End Function
我有隐藏的色带,导航窗格和所有访问用户界面,但我也需要删除Access背景。
电流:
任何帮助/建议将不胜感激。谢谢你的推荐!
答案 0 :(得分:4)
您不需要任何API代码。
以下设置应该可以解决问题:
文件 - &gt;选项 - &gt;当前数据库
取消选中“显示文档标签” 选择选项卡式文档。
在上面也取消选中显示导航窗格。
要隐藏功能区,请在启动时执行以下一行VBA:
DoCmd.ShowToolbar“Ribbon”,acToolbarNo
结果屏幕将是:
确保表单不是对话框,并确保它们不是弹出窗体。
要返回“开发”模式,退出数据库,然后按住shift键重新启动 - 这将绕过上述所有内容并允许您进行开发。
答案 1 :(得分:0)
我使用主窗体和Access窗口大小的同步,因此Access窗口将始终位于主窗口后面。这是背后的代码:
Private Sub Form_Resize()
'main form
'Let us know when Form is Maximized...
If CBool(IsZoomed(Me.hwnd)) = True Then
funSetAccessWindow (SW_SHOWMAXIMIZED)
DoCmd.Maximize
Me.TimerInterval = 0
ElseIf CBool(IsIconic(Me.hwnd)) = True Then
funSetAccessWindow (SW_SHOWMINIMIZED)
Me.TimerInterval = 0
Else
'enable constant size sync
Me.TimerInterval = 100
SyncMainWindowSize Me, True
End If
End Sub
Private Sub Form_Timer()
SyncMainWindowSize Me
End Sub
Public Function SyncMainWindowSize(frm As Form, Optional blnForce As Boolean = False)
Dim rctForm As RECT
Dim iRtn As Integer
Dim blnMoved As Boolean
Static x As Integer
Static y As Integer
Static cx As Integer
Static cy As Integer
#If VBA7 And Win64 Then
Dim hWndAccess As LongPtr
#Else
Dim hWndAccess As Long
#End If
If GetWindowRect(frm.hwnd, rctForm) Then
If x <> rctForm.Left Then
x = rctForm.Left
blnMoved = True
End If
If y <> rctForm.Top Then
y = rctForm.Top
blnMoved = True
End If
If cx <> rctForm.Right - rctForm.Left Then
cx = rctForm.Right - rctForm.Left
blnMoved = True
End If
If cy <> rctForm.Bottom - rctForm.Top Then
cy = rctForm.Bottom - rctForm.Top
blnMoved = True
End If
If blnMoved Or blnForce Then
'move/resize main window
hWndAccess = Application.hWndAccessApp
iRtn = apiShowWindow(hWndAccess, WM_SW_RESTORE)
Call SetWindowPos(hWndAccess, 0, x, y, cx, cy, WM_SWP_NOZORDER Or WM_SWP_SHOWWINDOW)
End If
End If
End Function
Function funSetAccessWindow(nCmdShow As Long)
'Usage Examples
'Maximize window:
' ?funSetAccessWindow(SW_SHOWMAXIMIZED)
'Minimize window:
' ?funSetAccessWindow(SW_SHOWMINIMIZED)
'Hide window:
' ?funSetAccessWindow(SW_HIDE)
'Normal window:
' ?funfSetAccessWindow(SW_SHOWNORMAL)
Dim loX As Long
On Error GoTo ErrorHandler
loX = apiShowWindow(hWndAccessApp, nCmdShow)
funSetAccessWindow = (loX <> 0)
End Function
答案 2 :(得分:0)