| DatabaseLessons.com |
'Serving the Microsoft® Access |
|
|
Using Text Files - Part 3In Part 1 of this series I briefly covered the importing of text files using the built in Import facility in MS Access. In Part 2 of this series I briefly covered the exporting of data to text files using the built in Export facility in MS Access. In part 3 let's take a look at import/export specifications. From the MS Access 2000 Help System we learn that, "An import/export specification contains information, such as file format, date order, or number formats, that Microsoft Access uses to import or export a fixed-width or delimited text file. Use an import/export specification when you want to repeatedly import to the same table, export to the same file, or automate the import or export process." Seems to me that the key reason to use import/export specifications is to help automate a common import or export process. An obvious scenario is the receipt on a daily basis of data from an external system. This data comes in a fixed format text file. That means you have to keep teaching your MS Access database where the fields start and stop, as there are no delimiters. Enter the specification ability of the import process. Let's follow through using an example. Here is a small piece of the file. T6587023010005 H7662002005006 Y5524120200150 Here is the same data with delimiters inserted, so you can see where the data is. (in our fictional sample, the system supplying the data cannot be modified to insert delimiters) T6587,023,010,005 H7662,002,005,006 Y5524,120,200,150 The process:
Now that we know that, how does it help us? (article continues after sponsor spot) The next time you need to import data from the same system, assuming the file format stays the same on each pass of the process, the import process is simpler.
This did not save you a ton of time, but what if there were 50 fields in that import file? Also, when we get to the VBA portion of this series, you will see the power of this system. NOTE: All the VBA code segments on the Database Lessons site assume that you have DAO references active. If you are not sure what this means, and you are using Microsoft Access 2000 or higher, click here. Happy Coding |
|
|
© 2006, 2007 Richard W. Killey. All Rights Reserved. |