hendafe wrote:
Thanks.
The commas are not going to be imported into the database.
I am supposed to use a command button in a form to import
these files. The command button is supposed to collect these
different text files in the folder and transfer these text into a table
in the Database.
Any ideas.
Yes, when you imported via MS-Access's build import function, Access
save a spec. Run the process again and click on advance which should
be through the left on any of the forms. Your DoCmd.transfer will need
to use than spec as well.
As for as running a routine to process multiple files via one button,
you'll need use VBA.
Here is a sample project I did for a client:
Function IndexPC()
Set fs = Application.Fil eSearch
LoadCount = 0
PathStr(0) = DLookup("[Input Dir]", "ImportSettings ", "[ID]
=0")
PathStr(1) = DLookup("[Archive Dir]", "ImportSettings ", "[ID]
=0")
PathStr(3) = DLookup("[Archive File]", "ImportSettings ", "[ID]
=0")
PathStr(4) = DLookup("[Purge File]", "ImportSettings ", "[ID]
=0")
CurrentDb.Execu te "Empty Files_New tbl"
With fs
For Counter = 1 To 1
.LookIn = PathStr(0)
.SearchSubFolde rs = False
.FileName = "*.PYX" 'Could be anything
If .Execute <> 0 Then
DoCmd.Echo True, "There were " & .FoundFiles.Cou nt & _
" file(s) found."
DoCmd.OpenForm ("LoadFiles" )
DoCmd.RepaintOb ject acForm, "LoadFiles"
For i = 1 To .FoundFiles.Cou nt
'If Forms![LoadFiles]![File Name] Is Not Null Then
DoCmd.GoToRecor d acForm, "LoadFiles" , acNewRec
Forms![LoadFiles]![File Path Name] = .FoundFiles(i)
Forms![LoadFiles]![File Name] = Dir(.FoundFiles (i))
Forms![LoadFiles]![File Size] =
FileLen(Forms![LoadFiles]![File Path Name])
Forms![LoadFiles]![File Date/Time] =
FileDateTime(Fo rms![LoadFiles]![File Path Name])
'
NeedOLE = "No"
Age = DateDiff("d", Forms![LoadFiles]![File Date/Time],
Date)
If DCount("[File Path Name]", "Files_Load ed", "[File Path
Name]='" & Forms![LoadFiles]![File Path Name] & "'") < 1 Then NeedOLE =
"YES" 'prevent reloading if already in main table
If Age > 30000 Then Call DeleteFile
If NeedOLE = "YES" Then Call LoadOLE
Next i
Else
' MsgBox "There were no files found."
End If
Next Counter
End With
DoCmd.SetWarnin gs False
DoCmd.OpenQuery "Append New Files"
CurrentDb.Execu te "Empty Files_New tbl"
DoCmd.Close acForm, "LoadFiles" , acSaveNo
If PathStr(3) = "-1" Then Call CopyAllFiles(Pa thStr(0),
PathStr(1), "*.*")
MsgBox "Loaded " & LoadCount & " Files."
End Function