涉及的使用步骤如下:
1. 在每个报表的Deactivate事件处理程序中写入:
DoCmd.Close acReport, Me.Name |
Dim CanClose as Integer |
CanClose = 0 |
If Not CanClose Then Cancel = True Forms!frmStart.Visible = True 'form is hidden when report is previewed DoCmd.SelectObject acForm, "frmStart" CloseForms CloseReports ' CloseForms and CloseReports close any open objects ' other than frmStart End If |
DoCmd.OpenReport "TheReport", acViewPreview,... Call sRemoveCaption(Reports("TheReport") |
这样的话,用户就能:
1. 看到报表
2. 在工具条操作
3. 最小化access
好了,如果用户想关闭access,可以主菜单来做到,但在报表预览窗口没有最小化、最大化以及关闭按钮。
'********************* Code Start ************************ 'This code was originally written by Terry Kreft & Keri Hardwick. 'It is not to be altered or distributed, 'except as part of an application. 'You are free to use it in any application, 'provided the copyright notice is left unchanged. ' 'Code Courtesy of 'Terry Kreft & Keri Hardwick ' Private Type RECT ' 16 Bytes left As Long top As Long right As Long bottom As Long End Type Private Declare Function apiGetWindowLong Lib "User32" _ Alias "GetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long) _ As Long Private Declare Function apiSetWindowLong Lib "User32" _ Alias "SetWindowLongA" _ (ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) _ As Long Private Declare Function apiGetWindowRect Lib "User32" _ Alias "GetWindowRect" _ (ByVal hwnd As Long, _ lpRect As RECT) _ As Long Private Declare Function apiGetSystemMetrics Lib "User32" _ Alias "GetSystemMetrics" _ (ByVal nIndex&) _ As Long Private Declare Function apiReleaseDC Lib "User32" _ Alias "ReleaseDC" _ (ByVal hwnd As Long, _ ByVal hDC As Long) _ As Long Private Declare Function apiGetDeviceCaps Lib "Gdi32" _ Alias "GetDeviceCaps" _ (ByVal hDC As Long, _ ByVal nIndex As Long) _ As Long Private Declare Function apiGetDC Lib "User32" _ Alias "GetDC" _ (ByVal hwnd As Long) _ As Long Private Declare Function IsZoomed Lib "User32" _ (ByVal hwnd As Long) As Long Private Declare Function ShowWindow Lib "User32" _ (ByVal hwnd As Long, _ ByVal nCmdShow As Long) As Long Private Declare Function MoveWindow Lib "User32" _ (ByVal hwnd As Long, _ ByVal x As Long, _ ByVal Y As Long, _ ByVal nWidth As Long, _ ByVal nHeight As Long, _ ByVal bRepaint As Long) As Long Private Declare Function GetParent Lib "User32" _ (ByVal hwnd As Long) As Long 'Use following instead of GetWindowRect Private Declare Function GetClientRect Lib "User32" _ (ByVal hwnd As Long, _ lpRect As RECT) As Long Public Const SW_MAXIMIZE = 3 Public Const SW_SHOWNORMAL = 1 Private Const GWL_EXSTYLE = -20 Private Const GWL_HINSTANCE = -6 Private Const GWL_HWNDPARENT = -8 Private Const GWL_ID = -12 Private Const GWL_STYLE = -16 Private Const GWL_USERDATA = -21 Private Const GWL_WNDPROC = -4 Private Const WS_CAPTION = &HC00000 Private Const WS_SYSMENU = &H80000 Private Const SM_CYCAPTION = 4 ' Height of caption or title Private Const TWIPSPERINCH = 1440 '** Window Style Constants Private Const WS_DLGFRAME& = &H400000 Private Const WS_THICKFRAME& = &H40000 Sub aTest() |
翻译: 朱亦文
来 源 于:MVPS: The access Web