Jeff,
Thanks for the quick response. I actually have a shart vb code doing a
loop
which I've tweaked over time. How would I modify this? Everything is based
upon two tables but could be 1 table and 2 queries. Query1 provides the
list
for parsing and Query2 the data to be parsed via 1 table.
Here's the code for a better view.
Private Sub cmdMakeTablesDOS_Click()
Dim strTableName As String
Dim strExcelFileName As String
Dim strSQL As String
Dim rstHQ As DAO.Recordset
Const SaveToDir = "C:\Documents and Settings\bb2130\Desktop\Sheets\"
'Open a recordset of all the ACM names
strSQL = "Select LVL3 from 000_DOSs"
Set rstHQ = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
Do Until rstHQ.EOF
'Make tables
strSQL = "SELECT *" _
& "INTO [" & rstHQ.Fields("LVL3") & "] " _
& "FROM 000_Metastorm_Assignments " _
& "WHERE [000_Metastorm_Assignments].[LVL3] = '" &
rstHQ.Fields("LVL3") & "' "
CurrentDb.Execute strSQL
'Export to Excel
strTableName = rstHQ.Fields("LVL3").Value
strExcelFileName = SaveToDir & strTableName & " Metastorm
Assignments " & Format(Date, "yyyy-mm-dd") & ".xls"
DoCmd.TransferSpreadsheet acExport, 8, strTableName,
strExcelFileName
'Do it again
rstHQ.MoveNext
Loop
End Sub
Jeff Boyce said:
Michael
If you have queries that are being used to "make tables", those are "Make
Table" queries, right? You could change them to simple Select queries.
Then, in your code, you could "export" the queries (what actually happens
is
the records returned by the query is what is exported).
Or have I misunderstood?
Regards
Jeff Boyce
Microsoft Office/Access MVP
I've tweaked some vb code which streamlines repetitive tasks.
Essentially
it
takes Table1 and parses it into individual tables based upon a list in
Table2
then exports each new table to excel.
How do I replicate this process without making the tables?