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

Using Import Specifications 1

Status
Not open for further replies.

arryb

Programmer
Oct 27, 2003
27
GB
I have written some VBA code to import a file with a click of a button from a CD. The file is not always the same name but always follows the following:

D:\????f3??.vp

Here is the code.

DoCmd.TransferText acImportDelim, "550 Invoice Records Import Specification", "Tab 550 Current Month", Dir("D:\????f3??.vp"), False, ""

The problem with this is that it cannot find the specified wildcard path unless i manually use the Get External Data function, select my import Spec, cancel it and then run the above code.
Likewise if i replace Dir("D:\????f3??.vp)" with the actual file location, ie D:\2170f323.vp, it also works. Any ideas what i have missed.

Cheers

Arry

 
Hi

You cannot just embed the Dir() function

You need to invoke a dialog with the used to identify the name of the input file, then use that in the DoCmd

Best to use the File Open Dialog box probably

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
You could also do the following:

Function FindMe() as String
With Application.FileSearch
.FileName = "*f3*.vp"
.LookIn = "D:\"
.SearchSubFolders = False
.MatchTextExactly=False
.Execute
End With
FindMe=Application.FileSearch.FoundFiles(1)
End Function

And in your main code:
Dim helper as string
...
DoCmd.TransferText acImportDelim, "550 Invoice Records
helper=FindMe
Import Specification", "Tab 550 Current Month",helper , False, ""

Would that do it?

MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
Thankyou.

That works a treat.

Many Thanks to you both for your time.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top