[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

MS Access - Importing text fields

Hello,
I am trying to use VBA to import my text file but nothing seems to work. If I run thwe import Wizard and do it manually, I can find my text file --> Select Delimited --> Select Tab --> Tick "Contains field names" --> Select predefined existing table --> Finish. This woks perfectly without a hitch. However if I run my below code I get an error;
DoCmd.TransferText acImportDelim, , strTable, strReportFilePath, False

It asks me for a specification but I do not know what to enter? any help please!!
0
andyb7901
Asked:
andyb7901
  • 4
  • 3
  • 2
  • +1
1 Solution
 
tbsgadiCommented:
Hi andy,

Have a look at How to Create and Save Data Export Specifications
http://support.microsoft.com/?id=209740

Good Luck!

Gary
0
 
peakpeakCommented:
Also look at the syntax and more for TransferText:
http://www.blueclaw-db.com/transfertext-docmd.htm
There's also a link to a working example of the command there
0
 
andyb7901Author Commented:
I dont particuarly want to save a specification as from my understanding it has to be in the same location as the text field I am importing, which is not feasible. Is there no way I can simply import my text field?
0
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
peakpeakCommented:
Yes, follow my tip above
0
 
andyb7901Author Commented:
The link above doesnt really help me. I am trying to import a file and the above is talking primarly about exporting, as per the download available. Why can I do this simply enough via the wizard and not via VBA?
0
 
Rey Obrero (Capricorn1)Commented:

follow this steps

to create an import specification

1. File>get external data>import
2. select in the File of types box   Text files (*.txt etc..
3. select the file
4 . in the import text wizard window select  delimited
5 .Click advanced
6. in the import specification window
    type the name of the field in the Field Name column
    (here you can use the field names of the destination table, specify data type,
      check the box Skip if you do not want to import the column)


7 click save as, give the specification a name  <-- this is the specification name that you will use in the command line below


   DoCmd.TransferText acImportDelim, "ImportSpecificationName", "myTableName", "C:\myText.txt", True
0
 
andyb7901Author Commented:
Where is the spcification saved though, or does this not matter? Will it just be stored local to the machine?
0
 
Rey Obrero (Capricorn1)Commented:
the import/export  specs are stored with the db.

see this images
ITW.jpg
TEISPEC.jpg
IESpec.jpg
0
 
andyb7901Author Commented:
Well thats good then. So if I transfer my DB to another location, the Specs wont be affected?
0
 
Rey Obrero (Capricorn1)Commented:
i already said that.  the import/export  specs are stored with the db.

So if I transfer my DB to another location, the Specs wont be affected? yes
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now