Run-time error 76

G

George

Dear friends,

I am using the following code - MS Access 2003 - Win XP, (found it in the
internet) and I am trying to autorecord in my table all files in my folder,
i.e. C:\MyData (it includes more or less 100 000 files in 6 000 folders).

I am getting the following error:
Run-time error 76 - Path not found

Is that due to the big number of files /folders found there, or is there
anything in code which should be replaced or added? I have used it to
autorecord less and works fine.

Secondly, my table tblFiles has a field called MyFile (txt-255). If I
change it to hyperlink (after recording using the code all filenames)
hyperlinks work great and open each file.

But if I set this field to hyperlink before recording all filenames the
hyperlinks do not work.

Any ideas will be higly appreciated.

GeorgeCY

Public Sub dirTest()

Dim dlist As New Collection
Dim startDir As String
Dim i As Integer
Dim strType As String


startDir = "C:\MyData\"
strType = "*.*"


Call FillDir(startDir, dlist, strType)

MsgBox "there are " & dlist.Count & " in the dir"

' lets printout the stuff into debug window for a test

Dim rstData As dao.Recordset
Set rstData = CurrentDb.OpenRecordset("tblFiles")
For i = 1 To dlist.Count
rstData.AddNew
rstData!MyFile = dlist(i)
rstData.Update
Next i
rstData.Close


End Sub


Sub FillDir(startDir As String, dlist As Collection, sType As String)

' build up a list of files, and then
' add add to this list, any additinal
' folders

Dim strTemp As String
Dim colFolders As New Collection
Dim vFolderName As Variant

strTemp = Dir(startDir & sType)

Do While strTemp <> ""
dlist.Add startDir & strTemp
strTemp = Dir
Loop

' now build a list of additional folders
strTemp = Dir(startDir, vbDirectory)

Do While strTemp <> ""
If GetAttr(startDir & strTemp) = vbDirectory Then
If (strTemp <> "..") And (strTemp <> ".") Then
colFolders.Add strTemp
End If
End If
strTemp = Dir
Loop

' now process each folder (recursion)
For Each vFolderName In colFolders
Call FillDir(startDir & vFolderName & "\", dlist, sType)
Next vFolderName

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