FileSearch with Access 2002 and XP doesn't work with *

J

Javier

Does anyone know how to use the wildcard with the
filesearch function? If I read from a network drive it
reads files from the directory but if I set it to read
from a local drive it doesn't find any files, eventhough
there are some in there. Please help! I have the
following sample code:

Function import_remisiones()

Dim fs, i, continuar
Dim Archivo As String
Dim Tcount As Integer

Set fs = Application.FileSearch
With fs
.newsearch
.lookin = "C:\Guanaco"
'.lookin = "F:\NotasRemision"
.SearchSubFolders = False
.filename = "*.txt"
If .Execute > 0 Then
'get count
Tcount = .foundfiles.count
continuar = MsgBox("Hay " & Tcount & " archivo
(s) que importar. ¿Desea continuar?", vbYesNo)
If continuar = vbYes Then
'importar
'For i = 1 To .foundfiles.count
For i = 1 To 1
Archivo = .foundfiles(i)
'DoCmd.TransferText
acImportDelim, "RemisionSpecs", "NotasRemision_Import",
Archivo
arc_archivo Archivo
Next i
MsgBox "Todas las Notas de Remision han
sido importadas. Ya puede correr el reporte de
Inventario Nuevo."
End If
Else
MsgBox "No hay Notas de Remision que
importar."
End If
End With

End Function
 
D

Dev Ashish

Does anyone know how to use the wildcard with the
filesearch function? If I read from a network drive it
reads files from the directory but if I set it to read
from a local drive it doesn't find any files, eventhough
there are some in there.

Use the more reliable Dir function instead.

Sub TestDirSize()
Const FOLDER = "C:\Temp\"
Dim tmp As String
Dim size As Long, count As Integer

tmp = Dir$(FOLDER & "*.mst")
Do While Len(tmp) > 0
count = count + 1
size = size + FileLen(FOLDER & tmp)
tmp = Dir
Loop
MsgBox "Count: " & count & vbCrLf & _
"Size: " & size
End Sub

-- Dev
 

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