Avatar billede hcm Nybegynder
09. september 2005 - 08:34 Der er 8 kommentarer og
1 løsning

40 rapporter i egne filer

Jeg har en rapport som jeg vil ha' exporteret til excel. Den bestaar af information som skal sendes til alle afdelinger, men det skal kun ha' deres egen information.
Jeg har styr paa at lave rapporterne saa de sendes til printeren, en per afdeling, men nu vil jeg gerne ha' skrevet dem til en excel fil, navngivet efter afdelingen.
Hvordan goer jeg nemmest det?
Avatar billede terry Ekspert
09. september 2005 - 12:03 #1
why do you want to send a report to Excel? Excel is used for calculations, not for showing reports!
Avatar billede hcm Nybegynder
09. september 2005 - 12:27 #2
Terry, I want to send it to Excel because the recepient in each department must make comments on each line and return it. This is much easier and handy in Excel than in Word
Avatar billede terry Ekspert
09. september 2005 - 13:27 #3
Is the report just ONE report which is grouped on department (afdeling)? If so then I think you need to change this so that one report is created for each department.

THis is just an idea.

If the report is based on a query then in the query you need a criteria for filtering a given department. You can set a criteria field in the query to "look" at a field on a form.

The criteria feld will look something like this

[forms]![YourForm]![FieldContainingDepartment]


Now you need some code in the form which loops through all departments, setting the field FieldContainingDepartment to the department.

For each department (in the loop) you first set the field and then you send the report in a mail as Excel using code something like this.

DoCmd.SendObject acSendReport, "YourReport", acFormatXLS, "WhoToGoesHere", , , "Excel Report"

where "WhoToGoesHere" is maybe a mailgroup for the department
Avatar billede hcm Nybegynder
09. september 2005 - 14:34 #4
That was was pretty much what I wanted! I have the looping working, but would like to just create a file in a specified folder instead of sending it directly as it needs to be bundled with other information...
So I guess I am just looking for a way of creating an excel file using VBA
Avatar billede hcm Nybegynder
09. september 2005 - 14:47 #5
Okay... I managed to solve it with this command:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "Query2", "X:\Test\File.xls", True

Thanks for the input Terry!
Avatar billede terry Ekspert
09. september 2005 - 15:45 #6
thanks

You could actually alter the file name to the department name so that you dont go overwriting the same file.

Have a good weekend
Terry
Avatar billede hcm Nybegynder
09. september 2005 - 15:47 #7
I am doing that already. Filename is a variable. Just wanted to post that I had found a solution so you didn't waste any time on this.

And a great weekend to you from London :-)
Avatar billede terry Ekspert
10. september 2005 - 09:18 #8
Do you live in London?
Avatar billede hcm Nybegynder
10. september 2005 - 10:39 #9
Yes. But still using Eksperten.dk :-)
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester