Rx_
Nothing In Moderation
- Local time
- Today, 04:33
- Joined
- Oct 22, 2009
- Messages
- 2,803
Not a problem - just an observation
Access 2007 - kind of interesting that the Read Only for this did not seem to speed things up when adding a timer at the beginning and Set myQDF = Nothing.
My test was using a single user, where perhaps when the database is being hit by a dozen users, it might make a difference.
Back in Access 97 days, there was some idea that read only was much faster.
Access 2007 - kind of interesting that the Read Only for this did not seem to speed things up when adding a timer at the beginning and Set myQDF = Nothing.
My test was using a single user, where perhaps when the database is being hit by a dozen users, it might make a difference.
Back in Access 97 days, there was some idea that read only was much faster.
Code:
Private Sub cmd_EntireBusiness_Click()
Dim myQDF As DAO.QueryDef
Dim myDBS As DAO.Database
Dim rstMgr As DAO.Recordset
Dim CustomSQLString As String, strTemp As String, strMgr As String
Const strFileName As String = "CustomerID"
Const strQName As String = "QueryToExport"
Set myDBS = CurrentDb
strTemp = myDBS.TableDefs(0).Name
CustomSQLString = "SELECT * FROM [" & strTemp & "] WHERE 1=0;"
Set myQDF = myDBS.CreateQueryDef(strQName, CustomSQLString)
myQDF.Close
strTemp = strQName
CustomSQLString = "SELECT DISTINCT [CustomerManager].[Store Billing] FROM qry_EntireBusiness;"
Set rstMgr = myDBS.OpenRecordset(CustomSQLString, dbOpenDynaset, dbReadOnly)
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
strMgr = DLookup("[CustomerManager].[Store Billing]",
"[CustomerManager]", "[Store Billing] = '" & rstMgr![Store Billing].Value &
"'")
CustomSQLString = "SELECT * FROM qry_EntireBusiness WHERE " & "[Store Billing] = " & strMgr & ";"
Set myQDF = myDBS.QueryDefs(strTemp)
myQDF.Name = strMgr
strTemp = myQDF.Name
myQDF.SQL = CustomSQLString
myQDF.Close
Set myQDF = Nothing
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
strTemp, "C:\Documents and Settings\Rx\Desktop\StudentID DB\" & strFileName & ".xls"
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
myDBS.QueryDefs.Delete strTemp
myDBS.Close
Set myDBS = Nothing