By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

FileSearch object in Access 2002

P: n/a
Has anybody encountered any problem with the Execute method or
FilesFound property of the FileSearch object in Access 2002? I have
this short routine that searches for a specific file that I'm having
problem with:

------
Dim fs, Flag as Integer
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Temp"
.FileName="Test.mdb"
'.Execute
'If .FilesFound.Count = 0 Then
If .Execute() = 0 Then
Flag = 0
Else
Flag = 1
End if
Debug.Print Flag
End With
------

The routine works on several machines except on one particular laptop.
There are no error messages and I am positive the file exists but it
seems the routine can't find the file. The Debug.Print always returns
0. I've tried other files in other locations but it still won't work
on this one particular machine.

I'd appreciate very much any ideas to resolve this. Thanks.

Wilson Tan
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
wm*****@aol.com (Wilson Tan) wrote in news:5d5bb7c.0402210629.7c92af51
@posting.google.com:
Has anybody encountered any problem with the Execute method or
FilesFound property of the FileSearch object in Access 2002? I have
this short routine that searches for a specific file that I'm having
problem with:

------
Dim fs, Flag as Integer
Set fs = Application.FileSearch
With fs
.LookIn = "C:\Temp"
.FileName="Test.mdb"
'.Execute
'If .FilesFound.Count = 0 Then
If .Execute() = 0 Then
Flag = 0
Else
Flag = 1
End if
Debug.Print Flag
End With
------

The routine works on several machines except on one particular laptop.
There are no error messages and I am positive the file exists but it
seems the routine can't find the file. The Debug.Print always returns
0. I've tried other files in other locations but it still won't work
on this one particular machine.

I'd appreciate very much any ideas to resolve this. Thanks.


Perhaps, you should verify the existence of the file with:

Public Function DoesFileExist(ByVal FilePath As String) As Boolean
With WizHook
.Key = 51488399
DoesFileExist = .FileExists(FilePath)
End With
End Function

Private Sub TestDoesFileExist()
MsgBox DoesFileExist("C:\Test\Temp.mdb")
End Sub

If it actually exists, you could search for other problems.

Of course, I think there is no reason that you could just not replace your
code with the function, as long as you won't be using any version < AC2K.
--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #2

P: n/a

Thanks, Lyle.

I replaced my codes with the function that you suggested. Problem is
solved. Anyway, just for curiousity, do you have any idea why
FileSearch would not work on that particular machine? I tried installing
Access 2K on that machine and FileSearch would work, but when I upgrade
it back to Access 2002, FileSearch won't work.

Again, thank you for your help. I really appreciate it.

Wilson
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #3

P: n/a
Wilson Tan <wm*****@aol.com> wrote in news:4037c680$0$201$75868355
@news.frii.net:

Thanks, Lyle.

I replaced my codes with the function that you suggested. Problem is
solved. Anyway, just for curiousity, do you have any idea why
FileSearch would not work on that particular machine?


Back in 1999 FileSearch erred on some types of files, including shortcuts,
(".lnk"). After it erred, it might not return the names of files further down
the directory list. So, one had to introduce error handling to its Execute
Method. I don't know if this is still the case, but I abanadoned FileSearch
at that time.

--
Lyle
(for e-mail refer to http://ffdba.com/contacts.htm)
Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.