By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,790 Members | 1,409 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,790 IT Pros & Developers. It's quick & easy.

import a textfile with vba

P: n/a
Hello,

I'm trying to import a textfile into an Access table. I want
to write a macro to do all the work automatically.

My textfile looks like that:
artNr;description;sellingValue
111111;top;0.34

The different colums are divided by ";" and the sellingValue is a
double datatype which is divided by ".".

I want to to create a table that looks like that:
artNr description sellingValue
111111 top 0,34

--------------
Datatypes:
artNr = text
description = text
sellingValue = double

Thanks a lot,
Mibi
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
HJ
There are several ways to do this. One is to use the Open and Input
commands, e.g.

Open YourTextFile.txt For Input As 1

For each line: Input #1, strInput until you meet an empty line (strInput="")
or error 62 (end of file).

Then you can split each line by searching for the ; characters.

HJ

<mi******@gmx.de> wrote in message
news:77**************************@posting.google.c om...
Hello,

I'm trying to import a textfile into an Access table. I want
to write a macro to do all the work automatically.

My textfile looks like that:
artNr;description;sellingValue
111111;top;0.34

The different colums are divided by ";" and the sellingValue is a
double datatype which is divided by ".".

I want to to create a table that looks like that:
artNr description sellingValue
111111 top 0,34

--------------
Datatypes:
artNr = text
description = text
sellingValue = double

Thanks a lot,
Mibi

Nov 13 '05 #2

P: n/a
Hmmmm, sounds like your looking to hard for the answer, search the
access help for the DoCmd.TransferText command, this will import or
export text files fairly simply.
Nov 13 '05 #3

P: n/a
use TransferText and create an import specification. Much easier.
Nov 13 '05 #4

P: n/a
Just go file->get external data, and follow the wizard.

You should be able to import this data with no code at all. The import
ability of ms-access is quite good, and likely you don't need any code here.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.