Well, here is a decidedly low-tech alternative to the above.
'----------------------------
Sub ReadDesktopFolder()
Dim lPid As Long
Dim cnn As ADODB.Connection
Set cnn = CurrentProject.Connection
lPid = Shell(Environ("COMSPEC") & " /c dir " & Chr(34) & "C:\Documents and
Settings\carlrj\Desktop\TestFolder" & Chr(34) & "\*.* /a:-d /b
cnn.Execute "Delete * from FolderNames"
DoCmd.TransferText acImportDelim, "Myfiles Import Specification",
"tblFiles", "c:\myfiles.txt", False, ""
End Sub
'-----------------------------
Basically, it executes a DOS command to write the filenames to a text file
on your C: drive. Then it empties your table and uses the Transfer Text to
import them into the table. Put it in a Module and run it. The first time
you do, you will get an error because you don't have an Import Spec.
Manually import the file once and save the import spec. From that point, it
should run.
On my website (
www.rogersaccesslibrary.com), is a small Access database
sample called "DirectoryList.mdb" which illustrates how to do this and shows
different alternatives including code that will suspend the execution of
your program until the DOS command finishes.
--
--Roger Carlson
MS Access MVP
Access Database Samples:
www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L