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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FileSearch Win 2000 Access 97 Error?

Status
Not open for further replies.

lameid

Programmer
Jan 31, 2001
4,212
US
I have an Access 97 database with code that executes fine under Win 9x. But under Win 2000 I receive the following error:

"Run-time error '5':
Invalid procedure call or argument"

This error occurs in the below code... I only included to the point that I receive the error. Any thoughts would be greatly appreciated. Note that strPath is a valid path and strType = &quot;BIL&quot;. I'm guessing there is some new security &quot;feature&quot; in Win 2000 that I have not found the information on. (As if the Text ISAM update wasn't a big enough pain <MS article Q239105>)

Function importfiles(strPath As String, strType As String)
Dim fs As Object
Dim i As Integer
Dim DB As Database, sqlstr As String
Dim strDest As String, strOrig As String
Set DB = CurrentDb
Set fs = Application.FileSearch
DoCmd.Hourglass True

If Right(strPath, 1) <> &quot;\&quot; Then
strPath = strPath &amp; &quot;\&quot;
End If

With fs
.newsearch
.LookIn = strPath
.SearchSubFolders = False
.FileName = &quot;*.&quot; &amp; strType
 
You can't use the FileSearch object by assigning it to an object variable. Even if you add a reference to the Microsoft Office 9.0 object library, the FileSearch class is not available for creating object variables. There is only one FileSearch object, and it's the one attached to the Application object.

What you need to do is get rid of the fs variable altogether, and change your With statement to:
Code:
    With Application.FileSearch
That will eliminate your problem. Rick Sprague
 
I made the change and finally tested it. No change.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top