【发布时间】:2021-05-11 06:22:49
【问题描述】:
我有一个 Access 数据库应用程序,它已分为前端和后端。后端位于所有用户都可以访问的共享网络驱动器上。我的问题是,当用户启动此应用程序的前端时,由于共享驱动器可能尚未在本地安装,因此他们没有与后端的连接,启动应用程序时显示的初始表单不会t 打开并让用户质疑发生了什么。我已经有代码来检查后端是否已连接,尽管由于某种原因,当它未连接时,介绍屏幕表单永远不会显示并且访问应用程序就在那里
Private Sub Form_Open(Cancel As Integer)
Dim strBackEndPath, LResult As String
Dim i, j, lenPath As Integer
'initialize variable status to 0
Me.BEDB_Status = 0
'define what to check in backend database
strBackEndPath = CurrentDb.TableDefs("VersionInfo-Available").Connect
' Now remove the datebase & password prefix
j = InStrRev(strBackEndPath, "=") + 1
strBackEndPath = Mid(strBackEndPath, j)
'Checking access to Backend database files...
Me.MessageText = "Checking access to Backend database files..."
On Error Resume Next
LResult = Dir(strBackEndPath)
'Set status to Length of LResult
Me.BEDB_Status = Len(LResult)
'Check length of BEDB_Status, if greater than 0, backend is connected. If 0, backend is not connected.
If Me.BEDB_Status > 0 Then
'length is greater than 0 so continue opening the app
DoCmd.OpenForm "IntroScreen"
Else
'length is 0 so backend is not connected. Alert user and quit the app
Me.MessageText = "The database isn't currently accessible. Program will now exit. Please ask the support team for assistance"
DoCmd.Quit acQuitSaveNone
End If
End Sub
【问题讨论】: