Import Txt Files Not Recognised By Access

D

DavidS

Hi
I'm try to apply the code as suggested Microsofts Knowledge Base Article-306144 however I get a Complie Error: Expected: Identifier. The purpose is to create a copy of a text file with an extentsion (ie tsv) that MS-Access does not recognise

The issue seems to be on the first line/string that I wrote as follows
Sub DataImport("c:\TablePayment.tsv", "MyTableData"
Also, do I need to replace any other parts of the code with my own name (ie strPath & strTableName)
Any suggestions would be really appreciated. Dav

The code is from
http://support.microsoft.com/default.aspx?scid=kb;EN-GB;306144#appliest
Sub DataImport(strPath As String, strTableName As String
'Variables used to create and modify the file extensio
Dim objFileSyste
Dim objFil
Dim strFileCopy As Strin
Dim intExtPosition As Intege

'Create an instance of the FileSystemObject to acces
'the local file syste
Set objFileSystem = CreateObject("Scripting.FileSystemObject"

'Use the GetFile method to return a File object corresponding to th
'file in a specified path
Set objFile = objFileSystem.GetFile(strPath
intExtPosition = InStr(objFile.Name, "."
If intExtPosition > 0 The
strFileCopy = Left(objFile.Name, intExtPosition - 1) & ".txt
Els
strFileCopy = objFile.Name & ".txt
End I

'Create a copy of the file with a .txt extensio
objFile.Copy strFileCopy, Tru
DoCmd.TransferText acImportDelim, , strTableName, strFileCopy, Tru
End Su

I replaced the first
 
C

Cheryl Fischer

David,

Access is unhappy that you changed the syntax in the first line of the
Procedure from:

Sub DataImport(strPath As String, strTableName As String)
to
Sub DataImport("c:\TablePayment.tsv", "MyTableData")

Return the procedure's first line to it's original syntax and put the
following "call" in the Click event of a command button or copy it to the
Immediate Window (Ctrl-G) and press Enter:

DataImport "c:\TablePayment.tsv", "MyTableData"


hth,
--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


DavidS said:
Hi-
I'm try to apply the code as suggested Microsofts Knowledge Base
Article-306144 however I get a Complie Error: Expected: Identifier. The
purpose is to create a copy of a text file with an extentsion (ie tsv) that
MS-Access does not recognise.
 
D

DavidS

Great, it works exactly like you said. Thanks for your reply. Best regard
Davi

----- Cheryl Fischer wrote: ----

David

Access is unhappy that you changed the syntax in the first line of th
Procedure from

Sub DataImport(strPath As String, strTableName As String
t
Sub DataImport("c:\TablePayment.tsv", "MyTableData"

Return the procedure's first line to it's original syntax and put th
following "call" in the Click event of a command button or copy it to th
Immediate Window (Ctrl-G) and press Enter

DataImport "c:\TablePayment.tsv", "MyTableData


hth
-

Cheryl Fischer, MVP Microsoft Acces
Law/Sys Associates, Houston, T


DavidS said:
Hi
I'm try to apply the code as suggested Microsofts Knowledge Bas
Article-306144 however I get a Complie Error: Expected: Identifier. Th
purpose is to create a copy of a text file with an extentsion (ie tsv) tha
MS-Access does not recognise
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top