Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Importing data to MS_Access

Status
Not open for further replies.

jabond007

Programmer
Jun 21, 2000
39
US
Hello

I am trying to import a txt file to an access database.....But i get the following error
"Field F1 does not exist in table APL"

I am using the following syntax

Dim appAccess As Object
Set appAccess = CreateObject("Access.Application.9")

On Error GoTo errData
appAccess.OpenCurrentDatabase "c:\Access\Trans.mdb", True
DoCmd.TransferText acImportDelim, , "APL", "c:\import\Hcm0600.txt"
Exit Sub
errData:
MsgBox "Error" & Err.Description
End sub

Could somebody tell me the reason for the error. Basically i need to load data from a text file to an access database.

Thanks [sig][/sig]
 
You could make a table in the Access database linked to your text file, then run an append query from the linked table to the table where you want the data. You can run the append query from VB Code whenever you need to import the data. [sig][/sig]
 
Thanks francis.

I have been using th DoCmd command with transfer text. But i have to give the name of the destination table as a non existing table. It creates a table. I dont need that. What i need is it to add records to an existing table...How do u use the link command...i havent tried it before.. [sig][/sig]
 
You can make a linked table in Access by
Table New Link Table
then point to the text file
The use the Link Text Wizard (it should come up automatically) to define the fields in the text file.

Then you create an Append Query to copy the data to the table where you want the records. [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top