code help exporting to Excel

C

corkster

Currently I am able to export to Excel all the coordinators each to
their own workbook and export the employees that are associated with
those coordinators within that workbook (the code below does this, John
Nurick was a big help with this code). What I would like is for the
employees to be exported to separate worksheet/tab within the workbook
for that coordinator instead of all in one worksheet.

Anyone have suggestions.

Dim strSQL As String
Dim dbD As DAO.Database
Dim qdfExport As DAO.QueryDef
Dim rscoordinator As DAO.Recordset
Dim strFileSpec As String

Set dbD = CurrentDb()
Set qdfExport = dbD.QueryDefs("Query3")
Set rscoordinator = dbD.OpenRecordset("Query4", dbOpenSnapshot)
Do Until rscoordinator.EOF

qdfExport.SQL = "SELECT * FROM Table2 WHERE [coordinator]=""" &
rscoordinator.Fields("coordinator").Value & " "";"


strFileSpec = "C:\1 corey projects\HEC\testing\" _
& rscoordinator.Fields("coordinator").Value & " " & Format(Date,
"mm-dd-yyyy") & ".xls"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query3",
strFileSpec, True, "" & (employee)
rscoordinator.MoveNext


Loop
 
C

corkster

corkster said:
Currently I am able to export to Excel all the coordinators each to
their own workbook and export the employees that are associated with
those coordinators within that workbook (the code below does this, John
Nurick was a big help with this code). What I would like is for the
employees to be exported to separate worksheet/tab within the workbook
for that coordinator instead of all in one worksheet.

Anyone have suggestions.

Dim strSQL As String
Dim dbD As DAO.Database
Dim qdfExport As DAO.QueryDef
Dim rscoordinator As DAO.Recordset
Dim strFileSpec As String

Set dbD = CurrentDb()
Set qdfExport = dbD.QueryDefs("Query3")
Set rscoordinator = dbD.OpenRecordset("Query4", dbOpenSnapshot)
Do Until rscoordinator.EOF

qdfExport.SQL = "SELECT * FROM Table2 WHERE [coordinator]=""" &
rscoordinator.Fields("coordinator").Value & " "";"


strFileSpec = "C:\1 corey projects\HEC\testing\" _
& rscoordinator.Fields("coordinator").Value & " " & Format(Date,
"mm-dd-yyyy") & ".xls"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query3",
strFileSpec, True, "" & (employee)
rscoordinator.MoveNext


Loop

Not sure if I posted in the right group? or do I need to clarify? I
am working on coding in mS access 2003 form needing vba code or
direction on how to procede. Any help is greatly appreciated.

Thanks
 
C

corkster

corkster said:
corkster said:
Currently I am able to export to Excel all the coordinators each to
their own workbook and export the employees that are associated with
those coordinators within that workbook (the code below does this, John
Nurick was a big help with this code). What I would like is for the
employees to be exported to separate worksheet/tab within the workbook
for that coordinator instead of all in one worksheet.

Anyone have suggestions.

Dim strSQL As String
Dim dbD As DAO.Database
Dim qdfExport As DAO.QueryDef
Dim rscoordinator As DAO.Recordset
Dim strFileSpec As String

Set dbD = CurrentDb()
Set qdfExport = dbD.QueryDefs("Query3")
Set rscoordinator = dbD.OpenRecordset("Query4", dbOpenSnapshot)
Do Until rscoordinator.EOF

qdfExport.SQL = "SELECT * FROM Table2 WHERE [coordinator]=""" &
rscoordinator.Fields("coordinator").Value & " "";"


strFileSpec = "C:\1 corey projects\HEC\testing\" _
& rscoordinator.Fields("coordinator").Value & " " & Format(Date,
"mm-dd-yyyy") & ".xls"

DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query3",
strFileSpec, True, "" & (employee)
rscoordinator.MoveNext


Loop

Not sure if I posted in the right group? or do I need to clarify? I
am working on coding in mS access 2003 form needing vba code or
direction on how to procede. Any help is greatly appreciated.

Thanks

Never mind I did figure this out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top