Access to Excel - Stuck

  • Thread starter Thread starter wimblebury
  • Start date Start date
W

wimblebury

Guest
:mad:

I really need to find a way to run a bit of code which exports a Access query to excel and automatically saves the workbook.

However it is not quite so straightforward - I need the code to create different workbooks based on the contents of a field within the query which will be duplicated (it is actually a school name and several hundred pupils will be attached to a school) and use this field (schoolname) as the excel filename.

It needs to be at a click of button - the code runs creates loads of different workbooks and then says done!!!

Please Please Help Me.
 
You need to use the "OutputTo" function in Access. This will output the results of your query. You can use Recordsets to get the value of your School for the filename. Search the forums for recordsets, there are lots of examples. You should be able to find all you need about the "OutputTo" function in the VBA help.
 
...or you can use DoCmd.TransferSpreadsheet

The name of the query will become the sheet name in XL. You can specify the workbook name as rMonkey pointed out above.

I know you want to loop through your schools and produce all the workbooks in one go, but get your head around the output methods mentioned here first...then you can add the loop.
 

Users who are viewing this thread

Back
Top Bottom