I built a macro to append data from an Excel worksheet to a shared Access Database (Access 2010).
When the macro runs it pulls the cell values and appends it as a single row in the Access table. I've tested it multiple times and it does a great job at appending the data.
The problem comes when the macro is done running. If I click on the database it instantly locks and will not let me open the database. The only way around this is to go into VBA and hit the reset button. For some reason this unlocks the database.
I went into the Access database and set the Options > Client Settings to No Locks.
Any ideas how to stop it from locking? Why doesn't the close method close the connection and release the DB?
Dim Db As Database
Dim Rs As Recordset
Dim ws As DAO.Workspace
Dim Path As String
Path = "X:\EKTT-Log.accdb"
Set ws = DBEngine.Workspaces(0)
Set Db = ws.OpenDatabase(Path, _
False, False, "MS Access;") ' Learn more http://msdn.microsoft.com/en-us/library/office/ff835343.aspx
Set Rs = Db.OpenRecordset("Results Log", dbOpenTable, dbAppendOnly, dbPessimistic) ' Learn more http://msdn.microsoft.com/en-us/library/office/ff820966(v=office.14).aspx
' Log At a Glance
If Sheets(">>>>").Cells(15, "G") <> "" Then
Rs.AddNew
Rs.Fields("CTYHOCN") = CTYHOCN
Rs.Fields("eCommerce Manager") = eComMgr
Rs.Fields("Timestamp Start") = TimeStart
Rs.Fields("Timestamp Finish") = TimeFinish
Rs.Fields("Global Web Page") = Sheets(">>>>").Cells(15, "B")
Rs.Fields("Keyword Target") = Sheets(">>>>").Cells(15, "G")
Rs.Fields("Est Search Vol") = Sheets(">>>>").Cells(15, "H")
Rs.Fields("Title Tag") = Sheets(">>>>").Cells(15, "C")
Rs.Fields("Meta Description") = Sheets(">>>>").Cells(15, "E")
Rs.Update
Else
'
End If
' Close database & resume screenupdating
Rs.Close
Db.Close
ws.Close
Set Rs = Nothing
Set Db = Nothing
Set ws = Nothing
Application.ScreenUpdating = True