Revised dB....
I used the DIR function to get the rest of the files to process (if any).
I used the Name statement to move the processed file.
Here is the select folder code (without the "modBrowseFolder" required module - see dB).
Code:
Option Compare Database
Option Explicit
'**************************************************
' NOTE: requires a reference to Microsoft Office xx Object Library
'**************************************************
Private Sub cmdImport_Click()
'set this to your default path
Const SourcePath As String = "C:\Accmdb\TestImport"
Dim SystemOperand As String
Dim FileYear As String
Dim JulianDay As String
Dim ghost As String
Dim Reporttype As String
Dim strImportFileName As String
Dim tmpFilePath As String
Dim sPath As String
Dim OldFile As String, NewFile As String
Dim ArchivePath As String
Dim How2PickPath As Integer '
'use default path or pick the path to the folder
'1 = folder picker
'2 = use constant path
'3 = get path from table
How2PickPath = 1
Select Case How2PickPath
Case 1 ' user selects the path
sPath = CurrentProject.Path & "\"
sPath = BrowseFolderExplorer("Select a Folder", msoFileDialogViewPreview, sPath)
Case 2 'hard code path
sPath = SourcePath
Case 3 'look up from table
sPath = DLookup("SourcePath", "tblPaths")
End Select
'where to move the files TO
ArchivePath = DLookup("ArchivePath", "tblPaths")
strImportFileName = ""
If Len(Trim(sPath)) > 0 Then
tmpFilePath = sPath
sPath = sPath & "\F*.txt"
Me.txtPath = sPath
'gets the first file that matches the specifications.
strImportFileName = Dir(sPath)
Do While strImportFileName <> ""
'-------------------------
'these are optional - just here to debug the code.
Me.txtFileName = strImportFileName
Me.txtSystemOperand = Left(strImportFileName, 1)
Me.txtFileYear = Mid(strImportFileName, 2, 2)
Me.txtJulianDay = Mid(strImportFileName, 4, 3)
Me.txtghost = Mid(strImportFileName, 7, 1)
Me.txtReporttype = Mid(strImportFileName, 8, 1)
'-------------------------
'---------------------------------
' Here is where you would process the text file
' and put the data into the correct tables
'---------------------------------
' give time to close the text file
DoEvents
'---------------------------------
' here you would move the text file to an archive folder.
OldFile = tmpFilePath & "\" & strImportFileName
NewFile = ArchivePath & "\" & strImportFileName
Name OldFile As NewFile
'---------------------------------
'Get the next file to process
strImportFileName = Dir
Loop
MsgBox "Done"
End If
End Sub
************************************
@rpeare,
I know I make mistakes, but its "ssANfu" not "Ssnafu. Please smack your computer and give it a time out!!