So I'm having this issue where I can successfully update a row but fail to retrieve one of its fields immediately after.
I have this piece of code in a module:
then in the form class I've defined a function to populate a form, I've also defined a transaction to be sure to not mess things up as this is a multiuser database (be/fe split, everyone has their own fe):
this transaction gets rolled back at the lockQuery point, I've debug printed myDb.recordsaffected and it shows 1 (as it should be) but the lockQuery doesn't retrieve a value UNLESS the referred table is open in the background.
where am I getting things wrong here?the code is pretty simple but I feel I'm missing something
I have this piece of code in a module:
Code:
Private objMyDB As DAO.Database
Public Function myDb(Optional bolRefresh As Boolean = False) As DAO.Database
If objMyDB Is Nothing Or bolRefresh = True Then
Set objMyDB = CurrentDb()
End If
Set myDb = objMyDB
End Function
then in the form class I've defined a function to populate a form, I've also defined a transaction to be sure to not mess things up as this is a multiuser database (be/fe split, everyone has their own fe):
Code:
DAO.DBEngine.BeginTrans
someUpdateQuery = "UPDATE sometable SET locktime = " & unixTimeVariable & ", " lockedBy = """ & Username & """ WHERE somecriteria
myDb.execute someUpdateQuery, dbFailOnError
if myDb.RecordsAffected > 0 then
lockQuery = SELECT id WHERE the above locktime AND the above username
set rs = myDb.openRecordset(lockquery, dbOpenDynaset, dbReadOnly)
if not rs.EOF then
lockedID = rs.fields("ID").value
end if
end if
If IsNull(lockedID) Or lockedID = "" Then
DAO.DBEngine.Rollback
exit sub
end if
DAO.DBEngine.CommitTrans
this transaction gets rolled back at the lockQuery point, I've debug printed myDb.recordsaffected and it shows 1 (as it should be) but the lockQuery doesn't retrieve a value UNLESS the referred table is open in the background.
where am I getting things wrong here?the code is pretty simple but I feel I'm missing something