Duplicate Records

B

Booga_Boy

Help!

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
 

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