Importing

G

Guest

There are 2 parts to my question

Im importing 35 files

1) I made a form where the user will select the directory on where the 35
files are located and then import them. My problem is that i am seeing in the
database, everytime someone imports, there are _import error tables that are
being created. Im guessing they are being created because that data doesn't
fit my import specification. I want to know if there is some code out there
where I can have those tables be deleted as soon as the upload process is
completed or better yet, never even be created

2) Now this database is being used by another dept. of my company. the files
that are being upload are daily files, which mean they have a date. I need a
way, as soon as the person locates the directory of the files and uploads all
teh files to my database, that there is a code to delete all the files from
that folder automatically. Reason is because my fear of them duplicating the
data.
 
D

David Lloyd

Justin:

Below is some sample code to address issue number two. I do not know how
you are performing your import, so this code was created in isolation with
respect to how the rest of the import process works. This code will delete
ALL files in the directory specified. All the usual disclaimers regarding
backing up your data and testing apply here. If have not referenced it
already, you will need a reference to the Microsoft Scripting Runtime to use
the FileSystemObject.

If I have time, I will try to address issue number one. If the import files
are text files, then the import errors table name for a file will be the
filename without the extension with "_ImportErrors" appended to it. If you
iterate through the TableDefs collection and look for the error table name
(or just the "_ImportErrors" portion), you can delete any import error
tables generated.

Function DeleteFiles()
Dim fso As New Scripting.FileSystemObject
Dim fld As Scripting.Folder
Dim fil As Scripting.File

Set fld = fso.GetFolder("C:\MyImportDirectory")

For Each fil In fld.Files
fil.Delete
Next fil

Set fso = Nothing
Set fld = Nothing
Set fil = Nothing

End Function

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.


There are 2 parts to my question

Im importing 35 files

1) I made a form where the user will select the directory on where the 35
files are located and then import them. My problem is that i am seeing in
the
database, everytime someone imports, there are _import error tables that are
being created. Im guessing they are being created because that data doesn't
fit my import specification. I want to know if there is some code out there
where I can have those tables be deleted as soon as the upload process is
completed or better yet, never even be created

2) Now this database is being used by another dept. of my company. the files
that are being upload are daily files, which mean they have a date. I need a
way, as soon as the person locates the directory of the files and uploads
all
teh files to my database, that there is a code to delete all the files from
that folder automatically. Reason is because my fear of them duplicating the
data.
 
G

Guest

Thanks, this code works perfectly
Dont' bother about the first question, i finally figured it out

question, my boss likes the idea of having the files be deleted after the
importation but he wants to have the code use DAO instead of Microsoft
Scripting Runtime.
I know Im asking alot, but do you know how to make it in DAO code rather
than Microsoft Scripting Runtime. Thanks
 

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