2016-08-21 125 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鍵 - 這將繞過上述所有條件並允許您開發。