Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


.docmd.transfertext via vb

Posted on 2005-03-10
Medium Priority
Last Modified: 2008-02-01
I am using VB 6 and referencing MS Access to transfer a text file into a table.

below is a section of code i am using:

Dim ACObject As Access.Application
Set ACObject = CreateObject("Access.Application")

With ACObject
    .OpenCurrentDatabase filepath:="" & App.Path & "\some_db.mdb "
    .DoCmd.TransferText acImportDelim, "ReaderSpec", "Hierarchy-20050310", strFilename, True

End With

i have never used the .docmd.transfertext..... and i am not sure what i need to specify in each of the fields.
i get an error message that states : Runtime error 3625....The text file specification 'ReaderSpec' does not exist . You can not import,export or link  using the  specification.

What is the correct syntax to use?

ok, in the specification area where i have  'ReaderSpec' .  I have placed an empty string in its place (""), now i get an error (runtime 2391) that says my field names do not exist in the destination table.

I have all the field names in the table.  I am not sure why i get this error.
Question by:JoannieJefferson
LVL 41

Accepted Solution

shanesuebsahakarn earned 2000 total points
ID: 13509946
In order to define an import spec (which you will need in this case), open the Access database, click File->Get External Data->Import. Choose text files. and go through the wizard, defining your options. When you reach the last page, click Advanced and click Save As. You can now save the spec asa ReaderSpec, which you can now use in your code as above.

Author Comment

ID: 13510127
It works.....Thank you!

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question