Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Public Sub CompactDB()
Dim FilePath As String
FilePath = InputBox("Enter Database Directory Path")
If FilePath = "" Then Exit Sub
On Error GoTo CompactDB_Err
' Compact the database to a temp file.
DBEngine.CompactDatabase FilePath & "\YourDB.mdb", FilePath & "\YourDBTemp.mdb"
' Rename the current database as backup and rename the temp file to
' the original file name.
Name FilePath & "\YourDB.mdb" As FilePath & "\YourDB.bak"
Name FilePath & "\YourDBTemp.mdb" As FilePath & "\YourDB.mdb"
MsgBox "Compacting is complete", vbInformation
Exit_CompactDB:
Exit Sub
CompactDB_Err:
MsgBox Err.Description, vbCritical
Resume Exit_CompactDB
End Sub
Public Function DBOpened(strDbPath As String) As Boolean
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim strConnect As String
Dim MyPC As String
' Format connection string to open database.
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDbPath
Set cnn = New ADODB.Connection
cnn.Open strConnect
' Open user information schema query.
Set rst = cnn.OpenSchema(Schema:=adSchemaProviderSpecific, SchemaID:="{947bb102-5d43-11d1-bdbf-00c04fb92675}")
DBOpened = True
'This gets the name of the local machine
MyPC = Environ("COMPUTERNAME")
With rst
Do Until .EOF
If Trim(!COMPUTER_NAME) <> MyPC Then
'If you want the user to know which machine the other user is on then use this err.raise statement
'Err.Raise 5001, "YourDB", "Database already opened on machine " & !COMPUTER_NAME
DBOpened = False
Exit Function
End If
.MoveNext
Loop
End With
End Function
'You attempted to open a database that is already opened exclusively by user 'Admin' on machine 'NT_ALAND'. Try again when the database is available.'