
Using WildCard (*) with .FileSearch.Filename in Access97 VBA with Windows 2000
I had a bit of
VBA code attached to a form used to search
for files in a corporate file directory related to a
specific record. All the files are
named "DUSRRRRBlahBlah.xxx" where DUS is the string "DUS",
RRRR is the record number (4 digits), BlahBlah is variable
and xxx is the file extention (mostly .wpd or .doc).
When I used to run this on an Access 97 form in Windows NT
or 95 it worked perfectly. In Windows 2000 the wild card
causes an error.
The code is
With Application.FileSearch
.LookIn = Directory
.FileName = "DUS" & Record & "*"
If .Execute(SortBy:=1, SortOrder:=1) > 0 Then
For i = 1 To .FoundFiles.Count
[snip]
Next i
Else
MsgBox "There were no files found."
End If
End With
With the & "*" it gives the error "Run-time error '5':
Illegal function call or argument"
Without the & "*" it returns no files.
Does windows 2000 not accept the wildcard? If not how do
I do a comparable search? Do I have to pull in the whole
file list and filter it myself?
Thanks,
Eric