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

DoCmd.TransferText to import text from a large text file

P: n/a
Hi. I'm new to this board and have a few questions about using the
method referred to in the topic of this message.

I have manually transferred over 1/2 million records from a text file
into my Access table in under 1 minute, using File>Get External
Data>Import, then specifying .txt as the data source, selecting
the text file, and walking through the resulting Wizard.

I'm thinking I can do the same thing with DoCmd.TransferText, but
don't understand all the parameters. The basic format is:

DoCmd.TransferText (TransferType, SpecificationName, TableName,
FileName, HasFieldNames, HTMLTableName, CodePage)

Here's what I have so far:

DoCmd.TransferText(acImportDelim,, "MyTable", "Path to text file"). I
don't think I need any of the last parameters. When I exit this line
in my VB6 app, however, I get the error message, "Compile error.
Expected =".

I think the key is including the SpecificationName, which I don't
understand. Any ideas? If SpecificationName is a path to some file
with import specifications, could someone also please explain the
format of this file and include an example?

My table has three fields, all text type, the first field indexed, no
primary key (don't need one). My text file contains comma delimited
rows such as:

Row1Field1Value, Row1Field2Value, Row1Field3Value
Row2Field1Value, Row2Field2Value, Row2Field3Value
etc...

Like I said, this imports in less than a minute manually in Access,
and I'm thinking will do the same from with my VB app.

Thanks ahead for help.

Nov 13 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rog
Do a manual import (Get external data / import), change the file type
to txt and click on Import. When the import text wizard opens, click
on Advanced. That's where you can define your import specification.

Nov 13 '05 #2

P: n/a
Hm, when working with Access 2003, I've seen this error pop up from
time to time. I've responded to it by removing parenthesis from
procedure calls (i.e. calls that don't return a value). So, try this
instead:

DoCmd.TransferText acImportDelim,, "MyTable", "Path to text file"

Nov 13 '05 #3

P: n/a
yeah no shit.. i think that is a bug in access also.

removing paranthesis shouldn't be necessary but these drunk monkeys in
redmond are too lazy to fix BUGS.

I have a laundry list of a dozen bugs in Access and Microsoft won't
FRIGGIN FIX THEM.

Nov 13 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.