E
ES
I had a discussion going on this yesterday but did not get it resolved. So I
set up a testing db with one form, one command button, and one module. Also
set the reference to Microsoft ActiveX Data Objects 2.7 Library. Can
someone try this and let me know why the db is locked when the form goes to
form view from design view.
If I open the form straight into form view, it runs fine BUT if I go into
design view I have to close the form then open in form view to get it to work
again.
Here is the Error:
“The database has been placed in a state by user ‘Admin’ on machine
‘1233455…†that prevents it from being opened or lockedâ€
Here is all the code in the test db.
Private Sub Command0_Click()
ADO_Test
End Sub
Public Sub ADO_Test()
Dim conn As ADODB.Connection
Dim strConn As String
Dim strSQL As String
On Error GoTo ERRORCATCH
'Create the ADO Connection object
Set conn = New ADODB.Connection
'Specify a valid connection string
strConn = "Data Provider=Microsoft.Jet.OLEDB.4.0;"
strConn = strConn & "Data Source = " & _
CurrentProject.Connection.ConnectionString
conn.ConnectionString = strConn
'Specify the Data Shaping provider
conn.Provider = "MSDataShape"
'Open the connection
conn.Open
MsgBox "connection open"
conn.Close
Set conn = Nothing
MsgBox "connection closed"
Exit Sub
ERRORCATCH:
If Err.Number = -2147217904 Then
MsgBox "File format not correct, please check file.", vbOKOnly
Err.Clear
Else
MsgBox "Unspecified data error. Please Check Database File for
correct table strucure.", vbOKOnly
Err.Clear
End If
End Sub
set up a testing db with one form, one command button, and one module. Also
set the reference to Microsoft ActiveX Data Objects 2.7 Library. Can
someone try this and let me know why the db is locked when the form goes to
form view from design view.
If I open the form straight into form view, it runs fine BUT if I go into
design view I have to close the form then open in form view to get it to work
again.
Here is the Error:
“The database has been placed in a state by user ‘Admin’ on machine
‘1233455…†that prevents it from being opened or lockedâ€
Here is all the code in the test db.
Private Sub Command0_Click()
ADO_Test
End Sub
Public Sub ADO_Test()
Dim conn As ADODB.Connection
Dim strConn As String
Dim strSQL As String
On Error GoTo ERRORCATCH
'Create the ADO Connection object
Set conn = New ADODB.Connection
'Specify a valid connection string
strConn = "Data Provider=Microsoft.Jet.OLEDB.4.0;"
strConn = strConn & "Data Source = " & _
CurrentProject.Connection.ConnectionString
conn.ConnectionString = strConn
'Specify the Data Shaping provider
conn.Provider = "MSDataShape"
'Open the connection
conn.Open
MsgBox "connection open"
conn.Close
Set conn = Nothing
MsgBox "connection closed"
Exit Sub
ERRORCATCH:
If Err.Number = -2147217904 Then
MsgBox "File format not correct, please check file.", vbOKOnly
Err.Clear
Else
MsgBox "Unspecified data error. Please Check Database File for
correct table strucure.", vbOKOnly
Err.Clear
End If
End Sub