Function testLockMode() If InStr(CurrentProject.Connection.ConnectionString, "Jet OLEDB:Database Locking Mode=0") > 0 Then MsgBox "本数据库已经用独占方式打开" Else MsgBox "本数据库未用独占方式打开" End If End Function
Function testLockMode() On Error Resume Next Dim conn As New ADODB.Connection conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=L:/IBM WinXP/desktop/mdb/重复记录.mdb;Jet OLEDB:Database Locking Mode=0;" If Err.Number = -2147467259 Then MsgBox "文件已经在使用中,估计是被别人以独占方式打开了" End If End Function