Hello all.
I have been trying to do something all day and I have partially succeeded at this point. Let me give you some background.
I have 26 xlsx files that are exported from an ERP system. Each file is about 60 megs and have around 500,000 lines of data.
What I'm trying to do, is import everything into access. I don't need all 26*500,000 lines, I actually need about 300,000 (in one single table)... All the rest will be filtered. I thus need to create a union query at some point.
Because the max size of a DB in Access is 2 GB. I can't just import everything using code, then run a query to filter everything and keep the 300k lines.
What I've been is the following:
- Write a VBA macro that imports all files in a folder into Access as separate tables
- After a file is imported, create a temporary query that filters the 500k lines just imported. Delete the query and the large table just imported. Keep just the query results (placed into a permanent using a select INTO table query).
This works very well, I'm sure it's not optimal, but it works. There's only one big problem... I can't do that for all 26 files because at one point the Access file will reach a 2 GB limit eventhough you will never have more than 500k lines at any point in time.
What is happening is that the manipulations are increasing the size of the DB and a Compact and Repair is required to reduce the size of the DB.
Example. If I import 8 out of 26 files, my DB size is 450 megs. When I run compact and repair the file size goes down to 50...
Unfortunately, from what I've read, there is no way to run a compact and repair from within the database... But there is apparently a way to do it on a closed Database.
So, I was thinking, please give me your opinion, to have two databases... One empty database that contains only VB code, and one database that contains the actual data. I don't even know if this is possible, I'm not Access expert.
What this would do is:
- Import the files in a closed database, execute queries in that same database. Delete the query and the original large tables-
- After about importing 8 tables; run a compact and repair which reduce the size of the file significantly
- Continue import etc. another 8 files, and continue.
Is this doable? How would I modify the code below to make it work on another database (where i can just specify the path of the DB that should contain the data)?
Thank you all in advance.
I have been trying to do something all day and I have partially succeeded at this point. Let me give you some background.
I have 26 xlsx files that are exported from an ERP system. Each file is about 60 megs and have around 500,000 lines of data.
What I'm trying to do, is import everything into access. I don't need all 26*500,000 lines, I actually need about 300,000 (in one single table)... All the rest will be filtered. I thus need to create a union query at some point.
Because the max size of a DB in Access is 2 GB. I can't just import everything using code, then run a query to filter everything and keep the 300k lines.
What I've been is the following:
- Write a VBA macro that imports all files in a folder into Access as separate tables
- After a file is imported, create a temporary query that filters the 500k lines just imported. Delete the query and the large table just imported. Keep just the query results (placed into a permanent using a select INTO table query).
This works very well, I'm sure it's not optimal, but it works. There's only one big problem... I can't do that for all 26 files because at one point the Access file will reach a 2 GB limit eventhough you will never have more than 500k lines at any point in time.
What is happening is that the manipulations are increasing the size of the DB and a Compact and Repair is required to reduce the size of the DB.
Example. If I import 8 out of 26 files, my DB size is 450 megs. When I run compact and repair the file size goes down to 50...
Unfortunately, from what I've read, there is no way to run a compact and repair from within the database... But there is apparently a way to do it on a closed Database.
So, I was thinking, please give me your opinion, to have two databases... One empty database that contains only VB code, and one database that contains the actual data. I don't even know if this is possible, I'm not Access expert.
What this would do is:
- Import the files in a closed database, execute queries in that same database. Delete the query and the original large tables-
- After about importing 8 tables; run a compact and repair which reduce the size of the file significantly
- Continue import etc. another 8 files, and continue.
Is this doable? How would I modify the code below to make it work on another database (where i can just specify the path of the DB that should contain the data)?
Thank you all in advance.