G
Guest
I have read quite a few posts regarding recordset coding but I could use some
advise. I have an Access database for multiple users. I have a form that
has a couple of dozen recordsets that delete records in tables for that user
and updates the tables/queries. At certain times during the day, my users
encounter run-time errors but when I resume through the code, they are just
fine. My questions are:
1. Should I be using the recordset type: table, dynaset or snapshot. I
tried using table and it seems to have a negative impact. I could also use
some guidance on the recordset options and lockedits (dbPessimistic is the
default).
2. I am wondering whether I should use dbEngine(0) (0) or CurrentDb. I
know dbEngine is faster and since I have many users, I think maybe it would
help.
Private Sub Final()
Dim dbFinal As DAO.Database
Dim RsFinal As DAO.Recordset
Dim RsECOA As DAO.Recordset
'Set dbFinal = DBEngine(0)(0)
Set dbFinal = CurrentDb
dbFinal.Execute ("Delete * from tblFinal where strMachineName = '" &
mstrCompName & "' ")
Set RsFinal = dbFinal.OpenRecordset("Select * from tblFinalLetter",
dbOpenDynaset)
'Set RsFinal = dbFinal.OpenRecordset("tblFinalLetter", dbOpenTable,
dbOptimistic)
RsFinal.AddNew
'here is where I build the recordset
RsFinal.Update
RsFinal.Requery
RsFinal.Close
Set RsFinal = Nothing
dbFinal.Close
Set dbFinal = Nothing
End Sub
advise. I have an Access database for multiple users. I have a form that
has a couple of dozen recordsets that delete records in tables for that user
and updates the tables/queries. At certain times during the day, my users
encounter run-time errors but when I resume through the code, they are just
fine. My questions are:
1. Should I be using the recordset type: table, dynaset or snapshot. I
tried using table and it seems to have a negative impact. I could also use
some guidance on the recordset options and lockedits (dbPessimistic is the
default).
2. I am wondering whether I should use dbEngine(0) (0) or CurrentDb. I
know dbEngine is faster and since I have many users, I think maybe it would
help.
Private Sub Final()
Dim dbFinal As DAO.Database
Dim RsFinal As DAO.Recordset
Dim RsECOA As DAO.Recordset
'Set dbFinal = DBEngine(0)(0)
Set dbFinal = CurrentDb
dbFinal.Execute ("Delete * from tblFinal where strMachineName = '" &
mstrCompName & "' ")
Set RsFinal = dbFinal.OpenRecordset("Select * from tblFinalLetter",
dbOpenDynaset)
'Set RsFinal = dbFinal.OpenRecordset("tblFinalLetter", dbOpenTable,
dbOptimistic)
RsFinal.AddNew
'here is where I build the recordset
RsFinal.Update
RsFinal.Requery
RsFinal.Close
Set RsFinal = Nothing
dbFinal.Close
Set dbFinal = Nothing
End Sub