The_Kurgan
Active Member
- Joined
- Jan 10, 2006
- Messages
- 270
Is there a way around the "file already in use" error? There are times when the code below gets halted when the DB is already open. Several people may be running this code at the same time and there's a chance this can happen.
Code:
'get data from Master table
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim stDB As String, stSQL As String, stProvider As String
stDB = "[URL="file://\\fimcfs001\CORP\Accounting-Shared\ReportingReporting\Access\xxx.accdb"]\\fimcfs001\CORP\Accounting-Shared\ReportingReporting\Access\xxx.accdb[/URL]"
stProvider = "Microsoft.ACE.OLEDB.12.0"
'Opening connection to database
With cn
.ConnectionString = stDB
.Provider = stProvider
.Open '<-------------------------------------------- HALTS HERE
End With
'Create the Recordset object
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
'1st - see if data has been saved to Master table
strSQL = "SELECT * FROM Master WHERE ID_Number = '" & Review.ListBox1.List(Review.ListBox1.ListIndex, 1) & "';"
rs.Open strSQL, cn, adOpenStatic, adLockBatchOptimistic
If rs.RecordCount = 0 Then GoTo NoneFound
rs.MoveFirst