473,395 Members | 1,532 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

FileSearch object in Access 2002

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
3 2574
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

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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
1
by: Mark | last post by:
Can anyone please tell me why the following code works fine in Win98/Access97, but fails to recognize files with a ".zip" extension in WinXP/Access2002/2000? It correctly lists the name of each...
1
by: | last post by:
Hi I am using Filesearch to find a list of files in a directory, and then to take the data and put it into an Access database. The code was working well within VBA and I have ported it into VB6,...
3
by: Bob Darlington | last post by:
I am looking at buying Installshield 11 Professional and Sagekey Access 2002 Runtime Object to facilitate the distribution of my Access 2002 application (having despaired with the PDW). One of the...
19
by: Alan Carpenter | last post by:
Access 8 on Win98 and WinXP I'm having trouble with wildcards in the .Filename property of the FileSearch Object giving different results on win98 and XP. I've been successfully using...
2
by: stuart.medlin | last post by:
I have recently converted an Access 97 database to Access 2003. However, I am running into a problem with using Application.Filesearch to locate a file in my directory. The code follows: ...
5
Lokean
by: Lokean | last post by:
At the top of my module I have Imports Microsoft.Office.Core Imports VBA Public Function rpu_process_files(Optional ByVal sFolderString As String = "", _ Optional ByVal sSearchString...
22
tdw
by: tdw | last post by:
We just added a new login name in our server for a girl named Courtney. She is using a computer that I used to use. The following code in our Orders Database has alway worked fine, but when she is...
3
by: MLH | last post by:
With Application.FileSearch .NewSearch .LookIn = "C:\My Documents" .SearchSubFolders = True .FileName = "Run" .MatchTextExactly = True .FileType = msoFileTypeAllFiles End With My code pukes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.