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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write data to table in Access from text file from VBA

Status
Not open for further replies.

gorcib

Technical User
May 11, 2004
12
SI
Hello!

I have text file in some format. I read it line by line and extract data I want from every line. How can I transfer these data to a table in MS Access using VBA?

Regards, Gorazd
 
How do I exactly tell to which table I want to write data?

Regards, Gorazd
 
Hi..

Please take a look at the TransferText command in Access help..

DoCmd.TransferText [transfertype][, specificationname], tablename, filename[, hasfieldnames][, HTMLtablename][, codepage]

not all parameters need to be used.. as is

DoCmd.TransferText acImportDelim,MySpec,"MyTable","C:\MyData.txt"

MySpec is created by first going to Access and doing a manual import, on the advance tab of the import, you will have the opportunity to save the import as a specification that can be used in the automatic import you are creating


 
Gorazd,

Hopefully the above will work for you, but it may not be what you're after. If not you may need to use VBScript (this can be referenced within VBA), if you post more detail of your data then I should be able to help.

Sharon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top