|
这是我的一个程序中使用的。Public Function gfProgInit()
On Error GoTo Err_proc Application.Echo False, "正在初始化程序运行环境..."
If Not gcflgDebug Then
DoCmd.SetWarnings False
gflgWarnings = False
Call gfDisableToolbars
Else
DoCmd.SetWarnings True
gflgWarnings = True
End If gflgRuning = False '2004/09/07
Do While Forms.Count > 0 '关闭所有已经打开的窗体
DoCmd.Close acForm, Forms(0).Name
Loop
Do While Reports.Count > 0 '关闭所有已经打开的报表
DoCmd.Close acForm, Reports(0).Name
Loop If CurrentProject.ProjectType = acMDB Then 'mdb
Call DLookup("EmpId", "tblEmployee") '测试链接表, 由错误处理程序刷新链接表
Else
If Not CurrentProject.IsConnected Then 'adp, 若未连接,则打开连接对话框
DoCmd.RunCommand acCmdConnection
End If
If Not CurrentProject.IsConnected Then ' 若仍未连接,则退出
Call modProgramInit.gfProgQuit
End If End If '公共变量初始化
gflgRuning = True Application.Echo True If gcflgMustLogin Then '开认证登陆窗
DoCmd.OpenForm "frmLogin"
DoEvents
Else
Call gfOpenMainForm
End If
Exit Function
Err_proc:
If Err.number = 3044 Or Err.number = 3024 Then
If CurrentProject.ProjectType = acMDB Then
Call fRefreshLinks
End If
Else
MsgBox "未知错误 " & Err.number & vbNewLine & Err.description, vbExclamation, gcstrMsgTitle
End If
Call modProgramInit.gfProgQuit
End Function |
|