Option Explicit
Dim mlngAutosizeWidth As String
Dim mlngAutosizeHeight As String
'Purpose : 自动尺寸调整 Author:Lynn_wang 2012-09-11
Private Sub Form_Load()
If Me.AutoResize Then
If Me.CurrentView = acCurViewDatasheet Then
mlngAutosizeWidth = 5940
mlngAutosizeHeight = 6045
' If mlngAutosizeWidth Or mlngAutosizeWidth Then
' Err.Raise &H400400, "Form_Load", "数据表视图下,你必须先设置 mlngAutosizeWidth 和 mlngAutosizeHeight"
' End If
Else
mlngAutosizeWidth = Me.WindowWidth
mlngAutosizeHeight = Me.WindowHeight
End If
Else
Err.Raise &H400400, "Form_Load", "此测试,窗体的 AutoResize 必须为真"
End If
Debug.Print Me.WindowWidth, Me.WindowHeight '这里可获得窗体的 AutoResize 在窗体视图下设置的值
End Sub
'Purpose : 切换视图 Author:Lynn_wang 2012-09-11
Private Function OpenWindows()
If Me.NewRecord Then Exit Function
If Me.CurrentView = acCurViewDatasheet Then
DoCmd.RunCommand acCmdFormView
DoCmd.MoveSize , , mlngAutosizeWidth, mlngAutosizeHeight '重设尺寸
Else
DoCmd.RunCommand acCmdDatasheetView
End If
End Function