First let me say I'm an absolute beginner with Access, but I know my way in Excel and have some basic knowledge of VBA.
So I have this query, selecting data from a linked ODBC table.
What it does is group by 3 fields (date, product, department), and sum a 4th field (sales), with filters (as specific as possible) on each of the 3 first fields. My objective is to get the total of daily sales for 1 given product and department, over the last 5 years.
Problem: the table is absolutely enormous (I estimate over 100 million records), and running the query for 1 day of data will take 5-10 minutes, and running it for several days will most likely timeout (I've already increased the ODBC timeout to 3000 seconds).
Since I can't simply run the query for all days at once (or even for 1 week at a time for that matter), I thought maybe I can make it an APPEND query and loop it using VBA, so it will run for 1 day at a time and keep adding the output to a table. It will take days to gether the data but that's not a major issue. However I really don't know how to do that.
Questions :
- How do I program this in VBA? Ideally I'd like something that can handle basic errors (the occasional timeout) so I can let it run overnight.
- What's the best way to manage the dates ? Not all days have data, so would it be useful to build a list of days which do have data for the VBA code to loop through ?
- How do I ensure I can stop the query, and have it restart where I left it ?
- Any suggestions on alternative ways to achieve my desired outcome are welcome! I can get assistance from developpers if needed, but would prefer handling it myself.
Thanks a lot in advance!
Laurent
So I have this query, selecting data from a linked ODBC table.
What it does is group by 3 fields (date, product, department), and sum a 4th field (sales), with filters (as specific as possible) on each of the 3 first fields. My objective is to get the total of daily sales for 1 given product and department, over the last 5 years.
Problem: the table is absolutely enormous (I estimate over 100 million records), and running the query for 1 day of data will take 5-10 minutes, and running it for several days will most likely timeout (I've already increased the ODBC timeout to 3000 seconds).
Since I can't simply run the query for all days at once (or even for 1 week at a time for that matter), I thought maybe I can make it an APPEND query and loop it using VBA, so it will run for 1 day at a time and keep adding the output to a table. It will take days to gether the data but that's not a major issue. However I really don't know how to do that.
Questions :
- How do I program this in VBA? Ideally I'd like something that can handle basic errors (the occasional timeout) so I can let it run overnight.
- What's the best way to manage the dates ? Not all days have data, so would it be useful to build a list of days which do have data for the VBA code to loop through ?
- How do I ensure I can stop the query, and have it restart where I left it ?
- Any suggestions on alternative ways to achieve my desired outcome are welcome! I can get assistance from developpers if needed, but would prefer handling it myself.
Thanks a lot in advance!
Laurent