View Full Version : Duplicate Control...


Lord Justin
01-15-2008, 07:52 AM
Hi,
I want to add folder names to my table. Without duplicate. But how? Here is the my code:

Dim FSO As New FileSystemObject
Dim f As Folder, sf As Folder

If FSO.FolderExists("C:\Test") Then
Set f = FSO.GetFolder("C:\Test\")
If Not f.SubFolders.Count = 0 Then

For Each sf In f.SubFolders

if not sf.Name in TestTable.TestField (Of course this code is not working. This is only a reference. Any idea for it? What can I replace it with?)

CurrentDb.Execute "INSERT INTO TestTable (TestField) VALUES('" & sf.Name & "')", dbFailOnError

Next
End If
End If

petehilljnr
01-15-2008, 10:13 AM
If DCount("*","TestTable","TestField = '" & sf.Name & "'") = 0 Then

Lord Justin
01-15-2008, 10:56 AM
Thank you very much... :p