adhoustonj
Member
- Local time
- Today, 16:42
- Joined
- Sep 23, 2022
- Messages
- 192
Hey AWF,
Hypothetically if I have a form event that had a
Which called 9 other functions in a module/subs such as TestMyCurrentDB2, 3, 4, etc - would I be essentially opening up 10 different "DB's", DAO.Databases, or what.
I tested recordsets a few days ago but unsure how to test DB's to fully understand what is going on.
For recordsets I did a similar exercise and just did a debug.print between events, subs, modules, and made sure all were outputting expected values. I'm unsure how to go about running a similar test with db's, so here I am if anyone would enlighten me please.
I'm asking this because I'm thinking about moving most of my database operations to be similar to the below
versus just executing strSQL statements.
Just curious.
Thanks all. Hope all is well.
Hypothetically if I have a form event that had a
Code:
Private Sub PlaceholderNameRoutine_Click()
Dim db as DAO.Database
Set db = currentdb()
'call function(i)
TestMyCurrentDB1
set db = nothing
End Sub
Which called 9 other functions in a module/subs such as TestMyCurrentDB2, 3, 4, etc - would I be essentially opening up 10 different "DB's", DAO.Databases, or what.
Code:
Public Function TestMyCurrentDB1()
Dim db as DAO.Database
set db = currentdb()
TestMyCurrentDB2
set db = nothing
End Function
I tested recordsets a few days ago but unsure how to test DB's to fully understand what is going on.
For recordsets I did a similar exercise and just did a debug.print between events, subs, modules, and made sure all were outputting expected values. I'm unsure how to go about running a similar test with db's, so here I am if anyone would enlighten me please.
I'm asking this because I'm thinking about moving most of my database operations to be similar to the below
Code:
Private Sub PlaceholderNameRoutine_Click()
Dim db as DAO.Database
Dim rs as DAO.Recordset
Dim strSQL as String
set db = currentdb()
strSQL = ".....x"
set rs = db.openrecordset(strSQL)
With rs
.addnew
.update
.edit
.update
rs.close
set rs = nothing
set db = nothing
End Sub
versus just executing strSQL statements.
Code:
Private Sub PlaceholderNameRoutine_Click()
Dim db as DAO.Database
Dim strSQL as string
strSQL = "INSERT INTO (xxxx) " & _
"VALUES ('"xxxxxxxx"')"
db.execute strSQL
strSQL = "UPDATE tblLaDiDa SET xxx = " & YugeNumber & ""
db.execute strSQL
set db = nothing
End sub
Just curious.
Thanks all. Hope all is well.