Hello all,
I am building an Access database to automate some processes in the office.
What I would like to do is after running some daily queries, to export all tables created with a date and time stamp.
I know this is a much asked feature because I can find many similar questions on the internet but since I am a complete newbie in using VBA code I cannot get it to work so now I am looking for help.
First I have tried to export only one table. I have created a sub like this:
Public Sub uitvoer()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "tbl_uitvalbak", "F:\debiteuren\Gijs\tbl_uitvalbak_" & Format(Date, "yyyymmdd") & ".xlsx"
End Sub
Since I need a function to use in my macro I then created a function and call the sub in there. Probably it doesn't make any sense but as said, I have no knowledge of vba and was just playing around. Like this:
Public Function uitvoeren()
Call uitvoer
End Function
Now the module looks like this in total:
Option Compare Database
Public Function uitvoeren()
Call uitvoer
End Function
Public Sub uitvoer()
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "tbl_uitvalbak", "F:\debiteuren\Gijs\tbl_uitvalbak_" & Format(Date, "yyyymmdd") & ".xlsx"
End Sub
If I run this in the VBA editor it works, but if I call the function from a macro it doesn't find the arguments and says I need to specify argument for the transferspreedsheet command.
So how do I provide the transferspreadsheet command with the required arguments?
When I finally get this to work I want to expand the function to be able to export an array of tables, like a 'for each' loop.
I would love to get some ideas from you guys on how to do this.
Many thanks!