MS Access: Linked Text File data doesn't change when pointed at a new file

97 views Asked by At

I have an MS Access (2013) Database that has multiple text files linked to it. I have written a VBA script to update the links to point to a new text file in a different location each week.

The problem is that no matter whether I do it manually or via the VBA script, the file will not display the new data in the new text file.

Can anyone suggest how to resolve this issue?

I have included the code below:

For J = 1 To 2

TblName = Choose(J, "Orders", "Pieces")
SpecName = Choose(J, "Orders 2015-03-16", "Pieces 2015-03-16")
strPath = GetDataPath(TblName)
SFileName = CurrentDb.TableDefs(TblName).SourceTableName
TxtFile = SFileName
MldFile = selectFile(TxtFile, strPath)
MldPath = Left(MldFile, InStrRev(MldFile, "\") - 1)
DoCmd.DeleteObject acTable, TblName
DoCmd.TransferText acLinkDelim, SpecName, TblName, MldFile, True
Next J

1

There are 1 answers

0
Edward On

I figured out that the problem was that the headers weren't updating, but the data was actually changing. I was able to fix this by eliminating the reference to the Specification, which works in this case. However, it won't work if you need to be specific about the data type for any particular field.