Get Directory Contents

B

Booga_Boy

Help! I've hit a roadblock.

I would like to populate a continuous form with the file contents of a
directory (Excel spreadsheets). I've already modified the Help example from
Access to be able to do this.

However, I get duplicate records. Is there a way to be able to iterate
through the current records on the form (or directory contents) and ONLY
populate the form with NEW contents from the directory? Any help would be
appreciated! Code is below . . .

Private Sub cmdPopulate_Click()

Set fs = Application.FileSearch

With fs
.NewSearch
.SearchSubFolders = True
.MatchTextExactly = True
.LookIn = Insert Directory Path Here
.FileName = Insert file name Criteria Here
If .Execute(SortBy:=msoSortbyFileName,
SortOrder:=msoSortOrderAscending) > 0 Then
For I = 1 To .foundfiles.Count
txtFile = .foundfiles(I)
Length = Len(txtFile)
txtFile = Right(txtFile, Length - 35)
DoCmd.GoToRecord , , acNewRec
Next I
End If
End With

End Sub
 
Top