Hi Rishi,
This can be done at the cost of learning some VBA. Probably the simplest
way is this:
1) I assume you already have a form that that the user will be looking
at when he/she wants to start the export process. If not, you need to
create one. I'll refer to it as frmXXX.
2) Put a commandbutton and a textbox on the form. Name the commandbutton
cmdExportToExcel, and set its Caption to Export. Name the textbox
txtManagerToExport.
3) Create a Select query based on your table, returning the fields you
need. In the ManagerNo column, in the Criteria row, put
[Forms]![frmXXX]![txtManagerToExport]
This makes it a parameter query that gets its parameter from the textbox
you have just put on the form. Save the query as qryExportManager
3) In the commandbutton's Click event procedure, write code like this.
Replace XXX with the actual name of your table:
Dim rsR As DAO.Recordset
Dim strWBK As String
strWBK = "D:\Folder\Filename.xls" 'filespec of workbook to create
'Open recordset with list of managers
Set rsR = CurrentDB.OpenRecordset( _
"SELECT DISTINCT ManagerNo FROM XXX;", dbOpenSnapshot)
Do Until rsR.EOF 'loop through the recordset
'set the textbox to the manager number
Me.txtManagerToExport.Value = rsR.Fields("ManagerNo").Value
'Export the query to a worksheet sheet with ManagerNo as name
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
"qryExportManager", strWBK, True, _
rsR.Fields("ManagerNo").Value
rsR.MoveNext 'next manager
Loop
'Tidy up
rsr.Close
If you want the user to be able to specify the name and location of the
Excel workbook, use the code at
http://www.mvps.org/access/api/api0001.htm.