andrewsmith
Registered User.
- Local time
- Today, 16:17
- Joined
- Oct 19, 2011
- Messages
- 15
I have an Access DB with a whole load of file imports coded in VBA. The files are a mixture of CSV and Excel. The system was originally coded in access but we are in the process of migrating to SQL server due to file size issues. However, the imports are still in Access and they write the data to SQL Server. Whilst importing the database is expanding and reaching the 2GB size limit. This then cuases a corruption and we have to restore from a backup.
To prevent this I have added a piece of code that checks if the DB is greater in size than 1.5GB before importing the next file. This seems to update as I break in the code but left to its own devices does nothing.
I have tried 2 techniques.
This was flakey even when breaking out at the if statement.So I tried:
Neither work as the code runs and the database expands away to over 2GB and corrupts.
Any help greatfully appreciated.
To prevent this I have added a piece of code that checks if the DB is greater in size than 1.5GB before importing the next file. This seems to update as I break in the code but left to its own devices does nothing.
I have tried 2 techniques.
Code:
Dim mdb As File
Set mdb = fso.GetFile(CurrentProject.Path & "\" & CurrentProject.Name)
'loop through files in folder
For Each f In fls
If mdb.Size / 1000000 > 1500 Then
MsgBox "File size greater than 1.5GB, Please process imported data into the SQL Server and compact database", vbCritical, "Database Expansion Error"
Exit For
Else
'file import code
This was flakey even when breaking out at the if statement.So I tried:
Code:
If FileLen(CurrentProject.Path & "\" & CurrentProject.Name) / 1000000 > 1500 Then
Neither work as the code runs and the database expands away to over 2GB and corrupts.
Any help greatfully appreciated.