chainedtodesk
Programmer
i have a table that can have anywhere from 10 -1000 records in it. these records are broken out by several buckets but have one field in common with another table. examples for testing included.
tble1 - mgrs which has 2 fields mgr#, mgrname. tble2 has mgr# and several other fields i need exported. i want the process to run through tble1 and create seperate excel files for each mgr with the tble2 data in it. need them in seperate excel files so they can be distributed accordingly.
here is code but it will not create any outfiles...
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Set dbs = CurrentDb
strSQL = "SELECT DISTINCT ManagerID FROM ManagersTable;"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
strSQL = "SELECT * FROM EmployeesTable WHERE " & _
"ManagerID = " & rstMgr!ManagerID.Value & ";"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
strTemp, "C:\" & strMgr & Format(Now(), _
"MMDDYYYY") & ".xls"
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.Close
Set dbs = Nothing
tble1 - mgrs which has 2 fields mgr#, mgrname. tble2 has mgr# and several other fields i need exported. i want the process to run through tble1 and create seperate excel files for each mgr with the tble2 data in it. need them in seperate excel files so they can be distributed accordingly.
here is code but it will not create any outfiles...
Dim dbs As DAO.Database
Dim rstMgr As DAO.Recordset
Dim strSQL As String, strTemp As String, strMgr As String
Set dbs = CurrentDb
strSQL = "SELECT DISTINCT ManagerID FROM ManagersTable;"
Set rstMgr = dbs.OpenRecordset(strSQL, dbOpenDynaset, dbReadOnly)
If rstMgr.EOF = False And rstMgr.BOF = False Then
rstMgr.MoveFirst
Do While rstMgr.EOF = False
strSQL = "SELECT * FROM EmployeesTable WHERE " & _
"ManagerID = " & rstMgr!ManagerID.Value & ";"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
strTemp, "C:\" & strMgr & Format(Now(), _
"MMDDYYYY") & ".xls"
rstMgr.MoveNext
Loop
End If
rstMgr.Close
Set rstMgr = Nothing
dbs.Close
Set dbs = Nothing