|
6#
楼主 |
发表于 2003-4-8 17:51:00
|
只看该作者
Function ap_LogOutCheck(strBackEndPath) As Integer
On Error Resume Next
ap_LogOutCheck = Dir(strBackEndPath & "\LogOut.FLG", vbHidden) = "LogOut.FLG"
End Function
Function ap_FormIsOpen(strFormName As String) As Integer
Dim frmCurrent As Form
For Each frmCurrent In Forms
If frmCurrent.Name = strFormName Then
ap_FormIsOpen = True
Exit Function
End If
Next frmCurrent
End Function
Function ap_GetDatabaseProp(dbDatabase As Database, strPropertyName As String) As Variant
ap_GetDatabaseProp = dbDatabase.Containers!Databases _
.Documents("UserDefined").Properties(strPropertyName).Value
End Function
Sub ap_SetDatabaseProp(dbDatabase As Database, strPropertyName As String, varValue As Variant)
dbDatabase.Containers!Databases.Documents("UserDefined").Properties(strPropertyName).Value = varValue
End Sub
Public Sub ap_LinkTables(dbLocal, dynSharedTables, strDataMDB As String)
Dim tdfCurrent As TableDef
Dim flgAddTable As Boolean
Dim intTotalTbls As Integer
Dim intCurrTbl As Integer
On Error GoTo Err_LinkTables
'-- Get the total number of linked tables, then display the progress meter.
dynSharedTables.MoveLast
intTotalTbls = dynSharedTables.RecordCount
dynSharedTables.MoveFirst
SysCmd acSysCmdInitMeter, "Linking Tables....", intTotalTbls
intCurrTbl = 1
Do Until dynSharedTables.EOF
'-- Update the progress meter
SysCmd acSysCmdUpdateMeter, intCurrTbl
'-- Attempt to open the current link
On Error Resume Next
Set tdfCurrent = dbLocal.TableDefs(dynSharedTables!TableName)
flgAddTable = Err.Number
On Error GoTo Err_LinkTables
'-- If there was an error, create the link from scratch,
'-- otherwise, just update the connect string
If flgAddTable Then
Set tdfCurrent = dbLocal.CreateTableDef(dynSharedTables!TableName)
tdfCurrent.SourceTableName = dynSharedTables!TableName
tdfCurrent.Connect = ";DATABASE=" & strDataMDB
CurrentDb.TableDefs.Append tdfCurrent
Else
tdfCurrent.Connect = ";DATABASE=" & strDataMDB
tdfCurrent.RefreshLink
End If
dynSharedTables.MoveNext
intCurrTbl = intCurrTbl + 1
Loop
Exit_LinkTables:
SysCmd acSysCmdRemoveMeter
Exit Sub
Err_LinkTables:
Resume Exit_LinkTables
End Sub
Public Sub ap_LogOutRemove()
On Error Resume Next
SetAttr pstrBackEndPath & "\LogOut.FLG", vbNormal
Kill pstrBackEndPath & "\LogOut.FLG"
End Sub
Public Sub ap_LogOutCreate()
On Error Resume Next
'-- Create flag file
Open pstrBackEndPath & "\LogOut.FLG" For Output Shared As #1
Close #1
SetAttr pstrBackEndPath & "\LogOut.FLG", vbHidden
End Sub
Public Function ap_LocateBackend(dbLocal, dynSharedTables, strCurrError) As Boolean
Dim ocxDialog As Object
ap_LocateBackend = True
DoCmd.Echo True
Beep
If MsgBox("A problem has occurred accessing the linked tables." & _
vbCrLf & vbCrLf & "The error was: " & strCurrError & vbCrLf & _
vbCrLf & "Would you like to locate the backend?", vbCritical + _
vbYesNo, "Error with Backend") = vbYes Then
Dim strFileName As String
strFileName = ap_FileOpen("Locate backend database", pstrBackEndName)
If Len(strFileName) <> 0 Then
DoEvents
ap_LinkTables dbLocal, dynSharedTables, strFileName
pstrBackEndPath = Left$(strFileName, _
InStrRev(strFileName, "\"))
Else
ap_LocateBackend = False
End If
El |
|