Re: Many File Import

From: John Nurick (j.mapSoN.nurick_at_dial.pipex.com)
Date: 06/30/04


Date: Wed, 30 Jun 2004 21:17:08 +0100

Hi Mike,

I think Joe envisaged having a form with an "Import all files" button.
This code would be in the button's Click event procedure. If you want to
specify the folder and filename at run-time, you can replace the
hard-coded lines
  ChDir ("c:\MyFiles")
 strfile = Dir("FileName*.*")
with something like
  ChDir Me.txtFolder.Value
  strfile = Dir(Me.txtFileName.Value)
where txtFolder and txtFilename are the names of textboxes on the form:
just type the names in.

If you remove the Kill line the files will stay where they are - but if
there's any interruption in the import process it won't be easy to tell
which files ahve been imported and which not. One approach would be to
copy the files you want into a temporary folder and import them from
there (with the Kill statement), leaving the originals undisturbed
elsewhere. ALternatively, use the Move statement to move each file
instead of Kill-ing it.

On Tue, 29 Jun 2004 08:25:43 -0700, "Mike"
<anonymous@discussions.microsoft.com> wrote:

>Thank You,
>
>Just one question. How/where would I go about setting
>this procedure up. And if I remove the Kill line, will
>the files just remain where they are?
>
>
>>-----Original Message-----
>>Hi Mike,
>>
>>This procedure - originally posted by Joe Fallon MVP -
>should get you
>>started:
>>
>>How to Import all Files in a Folder:
>>
>>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:\MyFiles")
>>strfile = Dir("FileName*.*")
>>Do While Len(strfile) > 0
>> DoCmd.TransferText
>acImportDelim, "ImportSpecName", "AccessTableName",
>>"c:\MyFiles\" & strfile, True
>> 'delete the file (consider moving it to an Archive
>folder instead.)
>> Kill "c:\MyFiles\" & strfile
>> strfile = Dir
>>Loop
>>
>>End Sub
>>
>>On Mon, 28 Jun 2004 05:44:50 -0700, "Mike"
>><anonymous@discussions.microsoft.com> wrote:
>>
>>>I need to import approximately 230 text files into
>>>access. Is there any way to import all 230 at one
>time.
>>>For instance, is there a way to import a whole folder or
>>>something like that.
>>
>>--
>>John Nurick [Microsoft Access MVP]
>>
>>Please respond in the newgroup and not by email.
>>.
>>

--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.