Hi All,
I have a problem linking to tables in an external Access database.
I have to run through a loop potentially 1000’s of times, and each time my code needs to link to an external table (depending on certain criteria), extract the data and manipulate it. Then my loop deletes the link and begins the whole process again. The code that I’m using to create the link is as follows:
The problem occurs initially at the beginning of the loop when I get a debug saying “Run-time error 3045. Could not use pathtodatabase\db.mdb; file already in use.” However, all I need to do after this debug is press continue or F5 etc, and the code continues running perfectly for the rest of the loop, without me having made any changes.
I have thought about incorporating some error handling, for example, that if Err.Number = 3045 then attempt to re-link again but this has been to no avail.
If it makes any difference – not that I think it does – it is actually already an external database (appAccess in my code snippet above) that is linking to external tables in yet another database. I.e. My main database (DB1) is running code and manipulating data in a secondary database (DB2) which is then linking to tables in a storage database (DB3).
Does anyone have any ideas as how to solve this issue?
With additional development it would be possible for me to have the all the data in one table (with potentially 100,000’s records) and then only need to link to it once. However, this would result in a loss of performance as my SQL queries would take far longer to extract the data because they would contain more “WHERE” clauses and would need to go through all the records finding the relevant data. Therefore, this is hopefully not a viable option.
I have a problem linking to tables in an external Access database.
I have to run through a loop potentially 1000’s of times, and each time my code needs to link to an external table (depending on certain criteria), extract the data and manipulate it. Then my loop deletes the link and begins the whole process again. The code that I’m using to create the link is as follows:
Code:
appAccess.DoCmd.TransferDatabase acLink, "Microsoft Access", strExternalDB, acTable, strTableName, "tblData"
The problem occurs initially at the beginning of the loop when I get a debug saying “Run-time error 3045. Could not use pathtodatabase\db.mdb; file already in use.” However, all I need to do after this debug is press continue or F5 etc, and the code continues running perfectly for the rest of the loop, without me having made any changes.
I have thought about incorporating some error handling, for example, that if Err.Number = 3045 then attempt to re-link again but this has been to no avail.
If it makes any difference – not that I think it does – it is actually already an external database (appAccess in my code snippet above) that is linking to external tables in yet another database. I.e. My main database (DB1) is running code and manipulating data in a secondary database (DB2) which is then linking to tables in a storage database (DB3).
Does anyone have any ideas as how to solve this issue?
With additional development it would be possible for me to have the all the data in one table (with potentially 100,000’s records) and then only need to link to it once. However, this would result in a loss of performance as my SQL queries would take far longer to extract the data because they would contain more “WHERE” clauses and would need to go through all the records finding the relevant data. Therefore, this is hopefully not a viable option.