I am trying to perform a DLookup to see if a record exists before I append a table. Any help to why my code is returning the error is greatly appreciated.
Error
The database has been placed in a state by user 'admin' in which it prevents it from being opened or locked.
Dim CurConn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim CurDB As Database
Set CurDB = CurrentDb
Set CurConn = New ADODB.Connection
With CurConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source= " & CurDB.Name
.Open
End With
Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
With rst
.Open "ServiceCenterProblem", CurConn, , , adCmdTableDirect
If IsNull(DLookup("[number]", "ServiceCenterProblem", "[number] = '" + Me!problem_number + "'") Then
MsgBox "Service Number Already Exists, Please enter a new Problem Ticket.", 48
Me!problem_number.SetFocus
.Close
Error
The database has been placed in a state by user 'admin' in which it prevents it from being opened or locked.
Dim CurConn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim CurDB As Database
Set CurDB = CurrentDb
Set CurConn = New ADODB.Connection
With CurConn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source= " & CurDB.Name
.Open
End With
Set rst = New ADODB.Recordset
rst.CursorType = adOpenDynamic
rst.LockType = adLockOptimistic
With rst
.Open "ServiceCenterProblem", CurConn, , , adCmdTableDirect
If IsNull(DLookup("[number]", "ServiceCenterProblem", "[number] = '" + Me!problem_number + "'") Then
MsgBox "Service Number Already Exists, Please enter a new Problem Ticket.", 48
Me!problem_number.SetFocus
.Close