MsAccess

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Dave1

MsAccess

Post by Dave1 » Wed Aug 11, 2004 3:44 am

Hi again,
I have a wish, but it is way over my head, to have a script that read text files, and import data into Access tables. Text files will be uniform in format, of course.
Is there a simple solution that would not require taking nite classes for the next 10 years to do?
Thanks

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Aug 11, 2004 4:25 am

Would need to know something about the format of the Access database, and the format/content of the text file.

But Macro Scheduler can read files line by line, can parse them, can insert delimiters, and make a complete file to be imported by Access.

I would suggest a comma/semicolon delimited file, but that might change based on text file content.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Aug 11, 2004 10:51 am

Use VBscript and ADO. ADO provides drivers for manipulating text files and access databases. So you can read in the text file record by record and output direct to the Access table.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Dave1

Post by Dave1 » Wed Aug 11, 2004 12:29 pm

Hi Bob,
I did picked up a tip from this forum about using
Vbstart
Vbend
Vbeval
to sparse the data and replace tab and spaces with coma delimeters, so that part I think I can handle.
Thanks as always for your great help.

Hi Marcus,
That ADO part seems to be the one I need.
I would like to construc a script to do something like this:

Read file1 (... and repeat to all files in a directory)
Read line1 (... and repeat to end of file)
Replace tab with coma
Replace space with coma
OUTPUT TO ACCESS TABLE

I can handle the first 4 lines, but the last one is my problem
For example, if I have something line this file

ControlStation1
Starter,Temperature,Date,Time
1,100,1/1/04,020202
2,110,1/1/04,020300
3,115,1.1.04,020001

The first line is the PK
The second line contains four separate fields
The third, and all other lines, contains the value for the fields in 2nd line respectively.

Importing these simple texts into Access table manually is easy. But I would very very very much learn how to use a script to handle this automatically.

Thanks greatly.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts