My Assistant
![]() ![]() |
|
|
Mar 15 2012, 05:37 AM
Post
#1
|
|
|
UtterAccess Enthusiast Posts: 74 From: Doha, Qatar |
Hi
I have a system which imports data from text files on a weekly basis. I have created links to the text files (which should come in an consistent format). My plan is to simply overwrite the text files (e.g. names and locations remain the same) when new ones become available and then kick of a routine which runs a number of queries to extract the data and update the system accordingly. I.e. I will not create new links, but leave the existing links as they are. The only change is that the text files themselves are replaced. In a recent test, when the text file was overwritten, Access failed to read it correctly, showing only one row of data (there are over 500,000) contain wacky character sets. There was nothing wrong with the file itself and when I deleted the existing link to the file and recreated it, everything worked fine. Has anyone here tried setting up something similar? Would I be better advised to delete the existing links and recreate them each time a new set of files arrives? Or is my current approach reasonable? As I say, the files should be identical in format every week. Thanks Paul |
|
|
|
Mar 15 2012, 06:09 AM
Post
#2
|
|
|
UtterAccess Editor Posts: 6,711 From: Capital District, NY, USA |
Hi,
I haven't worked with linking text files before, but I'm thinking that if you run a startup procedure to refresh the links, that might do it. Something like this: CODE Public Sub RefreshLinks() Dim db As DAO.Database Dim td As DAO.TableDef Set db = CurrentDb() For Each td In db.TableDefs td.RefreshLink Next td Set td = Nothing Set db = Nothing End Sub (you'd likely want to modify this to check the Connect property of the tabledef, and run the refresh method on only those that are connected to text files (you'll be able to tell by the Connect property) - this implementation refreshes ALL tables (including local tables with no Connect property - which may raise an error, not sure). hth |
|
|
|
Mar 15 2012, 06:33 AM
Post
#3
|
|
|
UtterAccess Enthusiast Posts: 74 From: Doha, Qatar |
Nice idea, thanks.
I'll set up some test scenarios/files shortly so I can see if I can recreate the problem and, if so, whether the RefreshLinks method solves it. |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 20th May 2013 - 01:00 PM |