C
corkster
I am trying to export to Excel using docmd.transferspreadsheet within
an MS Access 2003 Form. The code below automatically exports by
coordinator to a specific workbook and the employees associated with
that coordinator into multiple sheets for each employee within that
workbook. I know you can start exporting in a specific range of
fields, but with the code I have below I am not quite sure of the
syntax to do this. I would like to specify the starting cell in Excel
for it to export to (IE B1 cell). Please if you need more information
or this isn't the forum for this let me know.
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("qrytemp")
Set rscoordinator = dbD.OpenRecordset("Query2", dbOpenSnapshot)
Set rsemployee = dbD.OpenRecordset("Query2", dbOpenSnapshot)
Do Until rscoordinator.EOF
Do Until rsemployee.EOF
'qdfExport.SQL = "SELECT * FROM employee_coordinator WHERE
[coordinator]=""" & rscoordinator.Fields("coordinator").Value & " "";"
qdfExport.SQL = "SELECT * FROM employee_coordinator INNER JOIN data1 ON
employee_coordinator.emplid = data1.employeeid WHERE [coordinator] =
""" & rscoordinator.Fields("coordinator").Value & " "";"
qdfExport.SQL = "SELECT * FROM employee_coordinator INNER JOIN data1 ON
employee_coordinator.emplid = data1.employeeid WHERE [data1.employee] =
""" & rsemployee.Fields("employee").Value & " "";"
strFileSpec = "C:\1 corey projects\HEC\testing\" _
& rscoordinator.Fields("coordinator").Value & " " & Format(Date,
"mm-dd-yyyy") & ".xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qrytemp",
strFileSpec, True, " " & rsemployee.Fields("employee").Value
rscoordinator.MoveNext
rsemployee.MoveNext
Loop
Loop
Thanks
an MS Access 2003 Form. The code below automatically exports by
coordinator to a specific workbook and the employees associated with
that coordinator into multiple sheets for each employee within that
workbook. I know you can start exporting in a specific range of
fields, but with the code I have below I am not quite sure of the
syntax to do this. I would like to specify the starting cell in Excel
for it to export to (IE B1 cell). Please if you need more information
or this isn't the forum for this let me know.
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("qrytemp")
Set rscoordinator = dbD.OpenRecordset("Query2", dbOpenSnapshot)
Set rsemployee = dbD.OpenRecordset("Query2", dbOpenSnapshot)
Do Until rscoordinator.EOF
Do Until rsemployee.EOF
'qdfExport.SQL = "SELECT * FROM employee_coordinator WHERE
[coordinator]=""" & rscoordinator.Fields("coordinator").Value & " "";"
qdfExport.SQL = "SELECT * FROM employee_coordinator INNER JOIN data1 ON
employee_coordinator.emplid = data1.employeeid WHERE [coordinator] =
""" & rscoordinator.Fields("coordinator").Value & " "";"
qdfExport.SQL = "SELECT * FROM employee_coordinator INNER JOIN data1 ON
employee_coordinator.emplid = data1.employeeid WHERE [data1.employee] =
""" & rsemployee.Fields("employee").Value & " "";"
strFileSpec = "C:\1 corey projects\HEC\testing\" _
& rscoordinator.Fields("coordinator").Value & " " & Format(Date,
"mm-dd-yyyy") & ".xls"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qrytemp",
strFileSpec, True, " " & rsemployee.Fields("employee").Value
rscoordinator.MoveNext
rsemployee.MoveNext
Loop
Loop
Thanks