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.FileSearch
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.Execute "Empty Files_New tbl"
With fs
For Counter = 1 To 1
.LookIn = PathStr(0)
.SearchSubFolders = False
.FileName = "*.PYX" 'Could be anything
If .Execute <> 0 Then
DoCmd.Echo True, "There were " & .FoundFiles.Count & _
" file(s) found."
DoCmd.OpenForm ("LoadFiles")
DoCmd.RepaintObject acForm, "LoadFiles"
For i = 1 To .FoundFiles.Count
'If Forms![LoadFiles]![File Name] Is Not Null Then
DoCmd.GoToRecord 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(Forms![LoadFiles]![File Path Name])
'
NeedOLE = "No"
Age = DateDiff("d", Forms![LoadFiles]![File Date/Time],
Date)
If DCount("[File Path Name]", "Files_Loaded", "[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.SetWarnings False
DoCmd.OpenQuery "Append New Files"
CurrentDb.Execute "Empty Files_New tbl"
DoCmd.Close acForm, "LoadFiles", acSaveNo
If PathStr(3) = "-1" Then Call CopyAllFiles(PathStr(0),
PathStr(1), "*.*")
MsgBox "Loaded " & LoadCount & " Files."
End Function