Upload all Files in a folder code

J

jenni

Hello -
My code is below -
I found this is a previous post instructing how to upload
multiple files found in a designated folder all at once.

I attached this the the button and when I try to run it,
I get a "Syntax Error" message.
Any ideas where I went wrong???
Thank you!

........................................................

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete
them.
'assumes they are all the correct format for an ASCII
delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\jpfeifer.CCI\My
Documents\Mech\PR project\New472Format")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
DoCmd.TransferText([acImportDelim],[specs_Import472],
[tbl_472_Import],[(C:\Documents and
Settings\jpfeifer.CCI\My Documents\Mech\PR
project\New472Format) & strfile], [False]
'delete the file (consider moving it to an Archive
folder instead.)
Kill "C:\Documents and Settings\jpfeifer.CCI\My
Documents\Mech\PR project\New472Format" & strfile
strfile = Dir
Loop

End Sub
 
J

John Nurick

Hi Jenni,

Try compiling the code before you run it (on the Debug menu in the VBA
editor). That should show you where the problems are. One obvious thing
in your code is that in the DoCmd.TransferText statement you have used
square brackets [ ] around literal text: use quotes "" instead.

Hello -
My code is below -
I found this is a previous post instructing how to upload
multiple files found in a designated folder all at once.

I attached this the the button and when I try to run it,
I get a "Syntax Error" message.
Any ideas where I went wrong???
Thank you!

.......................................................

Private Sub btnImportAllFiles_Click()
'procedure to import all files in a directory and delete
them.
'assumes they are all the correct format for an ASCII
delimited import.
Dim strfile As String

ChDir ("C:\Documents and Settings\jpfeifer.CCI\My
Documents\Mech\PR project\New472Format")
strfile = Dir("FileName*.*")
Do While Len(strfile) > 0
DoCmd.TransferText([acImportDelim],[specs_Import472],
[tbl_472_Import],[(C:\Documents and
Settings\jpfeifer.CCI\My Documents\Mech\PR
project\New472Format) & strfile], [False]
'delete the file (consider moving it to an Archive
folder instead.)
Kill "C:\Documents and Settings\jpfeifer.CCI\My
Documents\Mech\PR project\New472Format" & strfile
strfile = Dir
Loop

End Sub
 

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