Bill wrote:
I'm trying to use a command button to the same thing as going to the
file menu and doing a Get External Data command to make the import
process easier for some end users. I'm using Access 2k, I have the
following code but I can't seem to get it to work properly.
Private Sub Command18_Click()
Dim strFileName As String
Dim strPath As String
strPath = "C:\ data" 'the location of the files
strFileName = "report.csv"
DoCmd.TransferText acImportDelim, "Data", strPath &
strFileName, "PC_Date", False
End Sub
Is there someone that can tell me what I'm missing or what I have
wrong.
Thanks
First, did you check the Access help? I've included a snippet from it
below.
It is hard to diagnose the problem when you don't tell us what happens
when you run the code? Nor do we get a clear indication of what "data"
and "PC_Date" are?
---------- From the Access Help
Syntax:
DoCmd.TransferText [transfertype][, specificationname], tablename,
filename[, hasfieldnames][, HTMLtablename][, codepage]
Remarks
You can leave an optional argument blank in the middle of the syntax,
but you must include the argument's comma. If you leave a trailing
argument blank, don't use a comma following the last argument you
specify.
----------
DoCmd.TransferText acImportDelim, "Data", strPath &
strFileName, "PC_Date", False
According to the syntax desscription your code reads:
Transfertype = acImportDelim (ok)
SpecificationName = "Data"
Tablename = strPath & strFileName
Filename = "PC_Date"
HasFieldNames = False
Don't forget to include commas for all the options even if you are
leaving them blank (except ones that are at the end of the line).
eg. No value given for specification, HTMLtablename, or Codepage
Docmd.TransferText acImportDelim, ,"tblMyTable", "c:\myfile.txt", False
--
regards,
Bradley
A Christian Response
http://www.pastornet.net.au/response