2016-08-21 206 views
0

启动我的MS Access 2013数据库时,我只需要显示启动窗体,而不需要其他东西。期望的结果将如下所示。背景是我的桌面。MS Access 2013仅显示启动窗体,没有其他东西

期望:

enter image description here

然而,当我打开数据库,窗体打开取整个屏幕。

下面的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 

我已经隐藏色带,导航窗格和所有接入的用户界面,但我需要删除访问后台也。

电流:

enter image description here

任何帮助/建议将不胜感激。感谢advace!

回答

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 
1

你不需要任何API代码。

下面的设置应该做的伎俩:

文件 - >选项 - >当前数据库

取消选中“显示文档选项卡” 选择选项卡式文档。

在上面还取消选中显示导航窗格。

要隐藏功能区中,在启动执行这一行的VBA:

DoCmd.ShowToolbar “丝带”,acToolbarNo

其结果的画面会是这样的:

enter image description here

确保表单不是对话框,并确保它们不是弹出窗体。

要回到“开发”模式,您需要退出数据库,然后重新启动按住Shift键 - 这将绕过上述所有条件并允许您开发。