C
CharlesNailen
Guest
I have an Access database, that I am running in Access from a O365 subscription. No one else accesses my database. I have a transaction function that executes an update statement when the main form loads. After that, I cannot do anything because I get a "You do not have exclusive access to this database" error. What is weird is that if I look in my .laccdb file, before the update, there is one entry with my laptop name, and the user name is Admin. After the update, there is a second entry, again with my laptop name, but this time, the user is admin. What the heck? I have searched the Internet and everything I have found as to how to solve the problem is for shared databases, but this is not a shared database. I have included my function code below. Any help would be greatly appreciated.
Update code:
strDashboardSQLStatements(intDashboardSQLRecordCount) = "UPDATE tbl_Dates SET tbl_Dates.Date_Inactive = -1 WHERE tbl_Dates.Course_Date < Date();"
bolDashboardTransaction = Execute_Transaction(strDashboardSQLStatements, 1)
If bolDashboardTransaction = False Then
DoCmd.Close acForm, "frm_Main_Dashboard"
DoCmd.OpenForm "frm_Main_Dashboard"
Exit Sub
End If
Function:
Function Execute_Transaction(ByRef strDashboardSQLStatements, intDashboardRecordCount) As Boolean
DAO.DBEngine.BeginTrans
On Error GoTo tranErr
intDashboardLoopCounter = 0
While intDashboardLoopCounter <= (intDashboardRecordCount - 1)
CurrentDb.Execute strDashboardSQLStatements(intDashboardLoopCounter), dbFailOnError
intDashboardLoopCounter = intDashboardLoopCounter + 1
Wend
DAO.DBEngine.CommitTrans
Execute_Transaction = True
Erase strDashboardSQLStatements
Exit Function
tranErr:
Execute_Transaction = False
DAO.DBEngine.Rollback
strMessageBoxString = MsgBox("Transaction failed with Error: " & Err.Description, vbOKOnly, "Transaction Failed")
Erase strDashboardSQLStatements
End Function
Thanks,
Chuck Nailen
Continue reading...
Update code:
strDashboardSQLStatements(intDashboardSQLRecordCount) = "UPDATE tbl_Dates SET tbl_Dates.Date_Inactive = -1 WHERE tbl_Dates.Course_Date < Date();"
bolDashboardTransaction = Execute_Transaction(strDashboardSQLStatements, 1)
If bolDashboardTransaction = False Then
DoCmd.Close acForm, "frm_Main_Dashboard"
DoCmd.OpenForm "frm_Main_Dashboard"
Exit Sub
End If
Function:
Function Execute_Transaction(ByRef strDashboardSQLStatements, intDashboardRecordCount) As Boolean
DAO.DBEngine.BeginTrans
On Error GoTo tranErr
intDashboardLoopCounter = 0
While intDashboardLoopCounter <= (intDashboardRecordCount - 1)
CurrentDb.Execute strDashboardSQLStatements(intDashboardLoopCounter), dbFailOnError
intDashboardLoopCounter = intDashboardLoopCounter + 1
Wend
DAO.DBEngine.CommitTrans
Execute_Transaction = True
Erase strDashboardSQLStatements
Exit Function
tranErr:
Execute_Transaction = False
DAO.DBEngine.Rollback
strMessageBoxString = MsgBox("Transaction failed with Error: " & Err.Description, vbOKOnly, "Transaction Failed")
Erase strDashboardSQLStatements
End Function
Thanks,
Chuck Nailen
Continue reading...