D
David Mueller
I often use the code toward the bottom of this post in my subs and
functions. For this one particular function it seems that as soon as I set
a DAO.TableDef object it falls out of scope. Sometimes, I can't even set the
TableDef object - but the table clearly exists. My code just doesn't work
consistently.
I saw a similar post that suggested the use of ....
Dim db = DAO.Database
Set db = currentdb()
.... would solve their problem (and apparently it did).
Can anyone tell me what the difference is between the above code and what I
routinely use (posted below)? Is the workspace the problem?
Thanks.
David
--- often used code starts here ---
Dim wsp As DAO.Workspace
Dim db_wsp As DAO.Database
Dim rst As DAO.Recordset
Dim rstOpen As Boolean
Set wsp = DBEngine.Workspaces(0)
Set db_wsp = wsp(0)
Dim fld As DAO.Field
Dim tdf As DAO.TableDef
Dim tdfs As DAO.TableDefs
Set tdfs = db_wsp.TableDefs <----- this sometimes can't be set
For each fld in tdfs <--- this falls out of scope immediately
functions. For this one particular function it seems that as soon as I set
a DAO.TableDef object it falls out of scope. Sometimes, I can't even set the
TableDef object - but the table clearly exists. My code just doesn't work
consistently.
I saw a similar post that suggested the use of ....
Dim db = DAO.Database
Set db = currentdb()
.... would solve their problem (and apparently it did).
Can anyone tell me what the difference is between the above code and what I
routinely use (posted below)? Is the workspace the problem?
Thanks.
David
--- often used code starts here ---
Dim wsp As DAO.Workspace
Dim db_wsp As DAO.Database
Dim rst As DAO.Recordset
Dim rstOpen As Boolean
Set wsp = DBEngine.Workspaces(0)
Set db_wsp = wsp(0)
Dim fld As DAO.Field
Dim tdf As DAO.TableDef
Dim tdfs As DAO.TableDefs
Set tdfs = db_wsp.TableDefs <----- this sometimes can't be set
For each fld in tdfs <--- this falls out of scope immediately