J
Jonno
Hi, VBA newbie needs rescuing. I am trying to export the same query with a
changing parameter (manager name) to the same destination and then run a
macro to do some formatting in excel for each sequence.
I have progressed to the following but its not picking up the Manager
reference, please could somebody help! or suggest alternate approach.
Function ExportMgr()
Dim mydb As DAO.Database
Dim myset As DAO.Recordset
Dim Manager as String
Set mydb = CurrentDb
Set myset = mydb.OpenRecordSet("Managers List")
Do Until myset.EOF
Manager = myset![Manager name]
CurrentDb.QueryDefs("ManagerQuery2").SQL = "SELECT* FROM ManagerQuery1 WHERE
Manager name = Manager"
DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel7,"ManagerQuery2","C:\Temp\Details.xls"
DoCmd.Run Macro Format
myset.MoveNext
Loop
End Function
changing parameter (manager name) to the same destination and then run a
macro to do some formatting in excel for each sequence.
I have progressed to the following but its not picking up the Manager
reference, please could somebody help! or suggest alternate approach.
Function ExportMgr()
Dim mydb As DAO.Database
Dim myset As DAO.Recordset
Dim Manager as String
Set mydb = CurrentDb
Set myset = mydb.OpenRecordSet("Managers List")
Do Until myset.EOF
Manager = myset![Manager name]
CurrentDb.QueryDefs("ManagerQuery2").SQL = "SELECT* FROM ManagerQuery1 WHERE
Manager name = Manager"
DoCmd.TransferSpreadsheet acExport,
acSpreadsheetTypeExcel7,"ManagerQuery2","C:\Temp\Details.xls"
DoCmd.Run Macro Format
myset.MoveNext
Loop
End Function