P
Parker
I am using a temporary db (created in code) to solve my mdb file size
growth problem. I have successfully created the tables I need in code,
used them, and deleted the temp DB on exit. However, I also have a
number of queries that are created on the fly. These are causing my
file size to bloat as well. I am trying to create these in the same way
I created the temp tables, but I cannot get it to work. Any help will
be immensely appreciated. Here is the code I am trying to use:
'CREATE QUERY IN TEMP DB
strQueryName = "searchQuery_Temp"
' Delete the link to the temp query if it exists
If queryExists(strQueryName) Then
CurrentDb.QueryDefs.Delete strQueryName
End If
' Create the temp query
Set qdfNew = dbsTemp.CreateQueryDef("")
With qdfNew
.Connect = "ODBC;DATABASE=" & strTempDatabase &
"DSN=Search_Table_Temp"
.SQL = "SELECT * from Search_Table_Temp;"
'Set rs = dbsTemp.OpenRecordset()
End With
dbsTemp.QueryDefs.Refresh
When using this code, I cannot get the query to appear in the temp DB
database window or in the current DB's window. Also, here is the code I
used to link the temp tables to my current DB. I cannot figure out how
to mofidiy this to work for the queries:
' Link to the Import tables in the temp MDB
Set tdfLinked = CurrentDb.CreateTableDef(strTableName)
tdfLinked.Connect = ";DATABASE=" & strTempDatabase
tdfLinked.SourceTableName = strTableName
CurrentDb.TableDefs.Append tdfLinked
growth problem. I have successfully created the tables I need in code,
used them, and deleted the temp DB on exit. However, I also have a
number of queries that are created on the fly. These are causing my
file size to bloat as well. I am trying to create these in the same way
I created the temp tables, but I cannot get it to work. Any help will
be immensely appreciated. Here is the code I am trying to use:
'CREATE QUERY IN TEMP DB
strQueryName = "searchQuery_Temp"
' Delete the link to the temp query if it exists
If queryExists(strQueryName) Then
CurrentDb.QueryDefs.Delete strQueryName
End If
' Create the temp query
Set qdfNew = dbsTemp.CreateQueryDef("")
With qdfNew
.Connect = "ODBC;DATABASE=" & strTempDatabase &
"DSN=Search_Table_Temp"
.SQL = "SELECT * from Search_Table_Temp;"
'Set rs = dbsTemp.OpenRecordset()
End With
dbsTemp.QueryDefs.Refresh
When using this code, I cannot get the query to appear in the temp DB
database window or in the current DB's window. Also, here is the code I
used to link the temp tables to my current DB. I cannot figure out how
to mofidiy this to work for the queries:
' Link to the Import tables in the temp MDB
Set tdfLinked = CurrentDb.CreateTableDef(strTableName)
tdfLinked.Connect = ";DATABASE=" & strTempDatabase
tdfLinked.SourceTableName = strTableName
CurrentDb.TableDefs.Append tdfLinked