Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File Search returns no results when the files do exists

Status
Not open for further replies.

snyperx3

Programmer
May 31, 2005
467
US
I'm using the following code to find files in a folder and add them to a list box.
Code:
Private Sub UpdateFileName()
    Set fs = Application.FileSearch
    fs.NewSearch
    fs.LookIn = "h:\archiveap"
    fs.Filename = "APACP" & ComboReportname.Value & "_" & ListYear.Value & ListMonth.Value & "*"
    fs.Execute
    For i = 1 To fs.FoundFiles.Count
        lstFiles.AddItem Dir(fs.FoundFiles(i))
    Next i
End Sub

This code does not find files on the server when the files clearly exists there. I've tried to find this error for a VERY long time now. I put it on a different computer that only had a G drive, and changed the code to use "g:\archiveap" and copied the files from the other computer to that folder, and it found them just fine. I don't understand.

Thanks for any help you can provide.


-Pete
 
Pete,
Just a thought:
1) Sounds like the troublesome computer is mapped to h: location; but if the code is running on a machine in which the network files are not mapped to h:, then problem of course. Have you tried using Network addressing (\\sharename\network folder\filename)?
2) What is different about the computer using h: and the one using g: as mappled locations? You've probably checked the full pathway for h: to ensure it's set up ok. Or, perhaps there's another difference in Network setup on the two machines?
Jeff
 
Jeff,
Thanks for the response.
1) The troublesome computer has a network drive H, and the one that is NOT troublesome has a network drive G. I have two different versions of this program (for testing purposes)..one with H and one with G, and I have them on the cooresponding computers. I just tried it with Network addressing as you suggested and I couldn't get any files to be found on either computer.
2) The only difference in the computers is that one is using a full copy of Access 2002 and the other is using Access 2002 Runtime, which I built using the packaging wizard I have with OfficeXP Developer. I checked the full pathway by using a messagebox to show the complete filename before the "fs" was executed, and I did a microsoft search for the file, and it was found, yet the "fs" did not return any files.



-Pete
 
Ok so the line that the problem occurs is:
fs.LookIn = "h:\archiveap"

on the computer that has runtime, this line apparently does not execute. I placed a msgbox after this line:
MsgBox(fs.LookIn)
and on my pc it returns the correct folder, but on the other pc it returns the MyDocuments folder of the current user.

How do i correct this?


-Pete
 
Just for giggles try replacing

h:\archiveap with

h:\archiveap\ and see what happens.


Andy Baldwin

"Testing is the most overlooked programming language on the books!
 
I ended up finding a different way to search for files. This is actually faster I think, and less code.
Code:
    Dim strFolderName As String
    strFolderName = Dir$("h:\archiveap\APACP" & ComboReportname.Value & "_" & ListYear.Value & ListMonth.Value & "*")
    
    Do Until strFolderName = ""
        lstFiles.AddItem strFolderName
        strFolderName = Dir$
    Loop

I did try your suggestion Andy, and it gave me the same results. I guess there is just a bug in the FileSearch. Anyway, thanks for your time and responses.



-Pete
 
Pete,
1. Could there be a connection problem between problem computer and the network? (Based on getting myDocuments vs. network location)
2. If file is found through one PC but not other, could there be different server used that restricts searches or has no indexing capability needed for searches?
3. Of course is code the same on both test machines?
4. What is different between problem environment and happening environment: PC hardware, operating system, version of Access (Run-time vs. ...), physical connection to network, servers connected to, ...???
Jeff
 
Jeff, thanks for your response. I've already resolved the problem by using the above code. Just in case someone else has this problem I will go ahead and answer your questions:
1) The problem computer is definately on the network. I can view the files by browsing to them on H.
2) These are on different servers that are set up EXACTLY the same except i have the folder on G for one, and the folder on H for the other. They are using Novell Netware.
3) The code is different on the machines but only in the effect of one machine is using server G, and the other is using server H.
4) The working computer is using Access 2002, and the non-working computer is using Access 2002 Runtime (as I stated in a previous post on this thread).

Like I said, using the newly posted code with the "Dir$" function made everything work perfectly.

Thanks for your time.



-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top