Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / July 2005

Tip: Looking for answers? Try searching our database.

text file import problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 26 Jul 2005 21:58 GMT
I'm trying to import a text file.  Here's a sample:

"89","000000","890828","01","PER","        .00","        .00","END="
"89","000001","890828","01","PER","        .00","        .00","END="
"89","000002","890828","01","PER","    2755.12","    2755.12","END="

And here's my code:

'------------------------------------------------------------
'    import the dadgum text file with our data
'
   Set DAOrs = DAOdbs.OpenRecordset(strTblName)

   DoCmd.TransferText acImportDelim, , strTblName, strPathName, 0
   
   DAOrs.Close
   Set DAOrs = Nothing

which is *supposed* to tell Access (2k) that my file has no field names.  But I
keep getting this error:

Field 'F1' doesn't exist in destination table '<MyTableName>'.  I get the same
msg for all my input files.

Anyone know what I'm missing?  Doing?  Not doing?

Thanks in advance,

Tom
Dirk Goldgar - 26 Jul 2005 23:13 GMT
> I'm trying to import a text file.  Here's a sample:
>
[quoted text clipped - 25 lines]
>
> Tom

You need to create an import specification, and give the name of that
specification in your call to TransferText.  If you don't, Access uses
the default target field names that the import wizard uses:  F1, F2, F3,
etc.

Incidentally, I don't see what you are trying to accomplish by opening a
recordset on the target table before importing, and then closing it
afterward.  This is not a necessary part of the import.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Tom - 27 Jul 2005 00:49 GMT
>> I'm trying to import a text file.  Here's a sample:
>>
[quoted text clipped - 30 lines]
>the default target field names that the import wizard uses:  F1, F2, F3,
>etc.

In all the reading I did, I *thought* that the spec was optional...but
the import would still work if the table existed.  I understand I was
wrong.

>Incidentally, I don't see what you are trying to accomplish by opening a
>recordset on the target table before importing, and then closing it
>afterward.  This is not a necessary part of the import.

I thought I needed to.  I stand corrected.

Thanks a lot,

Tom
Dirk Goldgar - 27 Jul 2005 00:53 GMT
> In all the reading I did, I *thought* that the spec was optional...but
> the import would still work if the table existed.  I understand I was
> wrong.

That's how I'd have interpreted the help topic for the TransferText
method on first reading, too.  The help topic for the TransferText
*action* is a little clearer.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.