Need a way to have my import routine filter out bad records.

D

dbguy11

I have simple import routine that pulls any txt file from a selected folder
and uses an import spec I created puts the txt file into a table I created in
Access. What is the best way to filter out bad records during the import.
Right now I use a delete query and just delete any record with a null value
in the Unit Price field. There is also a Type Code field that is always 207
if it is a good record and I could filter it that way. Below is the import
routine I use, if you have any suggestions on how to change to filter the bad
records I would appreciate it very much. Thanks in advance for any assistance
you can provide me.

Function btnImportAll()
Dim strfile As String

ChDir ("c:\PX06")
strfile = Dir("*.*")
Do While Len(strfile) > 0
DoCmd.TransferText acImportDelim, "PX06", _
"PX06", "c:\PX06\" & strfile, True
Kill "c:\PX06\" & strfile
strfile = Dir
Loop

End Function
 
K

Klatuu

Rather than identifying the destination as the table, use an append query
that will filter the records during the import.
 

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