FileSearch Object

V

Vivek

Hello,

I am using the FileSearch object to search for database
files. But the problem is this object is searching
for .ldbs and also the shortcuts. I just want the .mdbs

Any please help. Here is the code i have written.

Public Sub FindDatabases()

Dim strFileName As String, i As Integer,
rsDatabaseName As Recordset

Set rsDatabaseName = CodeDb.OpenRecordset
("tblDatabaseNames", dbOpenDynaset)
With Application.FileSearch
.NewSearch
.LookIn = "K:\RFCCom\RCG-PROD\"
.SearchSubFolders = True
.FileName = "*.mdb"
'.MatchTextExactly = True
.FileType = msoFileTypeDatabases
.MatchAllWordForms = False
If .Execute > 0 Then
MsgBox "There were " & .FoundFiles.Count & _
" file(s) found."
For i = 1 To .FoundFiles.Count
'MsgBox .FoundFiles(i)
rsDatabaseName.AddNew
rsDatabaseName!DatabasePath
= .FoundFiles(i)
rsDatabaseName.Update
Next i
Else
MsgBox "There were no files found."
End If

End With
MsgBox "All Databases Names Added"
rsDatabaseName.Close
Set rsDatabaseName = Nothing

End Sub

Thanks

Vivek
 
C

Cheryl Fischer

Vivek,

Using Office XP/Access 2002 SP-2 (on Windows XP Pro), I do not see the
behavior you describe. In Access 2002, the only properties/methods required
in code to return only .MDB files are:

.NewSearch
.LookIn = "K:\RFCCom\RCG-PROD\"
.SearchSubFolders = True
.FileType = msoFileTypeDatabases

In your version of Office/Access are you up to date on Service
Packs/Releases? How about for Windows?
 
V

Vivek

Hi Cheryl,

I am using Access 97. It's on SR - 2. I am trying this
on Windows NT Workstation.

Thanks

Vivek
 
C

Cheryl Fischer

I do not have an NT box where I can check this out for you, so here are some
other things to check:

1. Make sure that SR-2 has been applied to all of Office 97, not just
Access 97. This is because the FileSearch object is a part of Office, not
Access, and you will want to be sure that the Microsoft Office 8.0 Object
Library is current.

2. Based on a search of the MS KB, http://support.microsoft.com, searching
on FileSearch Access 97, there are reported problems with using the
FileSearch object and Access 97 on Windows 2K which was based on NT. So,
this could be an OS issue - perhaps.
 
D

Dev Ashish

I am using Access 97. It's on SR - 2. I am trying this
on Windows NT Workstation.

If I'm not mistaken, FileSearch had some problems in Access 97 version. It
wasn't totally reliable. In some cases, Win2K SP2 fixed the problem, but
you're running Win NT.

Try searching groups.google.com for Dir$ samples (couple have been provided
in this newsgroup in the last week). Another option is to use the APIs
directly. See

[ http://www.mvps.org/access/modules/mdl0051.htm ]

-- Dev
 
V

Vivek

Thanks Cheryl for the feedback. I have checked the
Service packs and all of them are on SR-2s and the object
Library is also current. I don't know if it's a OS issue
or Office issue.

I probably might have to try a different way to complete
this task.

But anyhow thank's very much for the help.

Vivek

-----Original Message-----
I do not have an NT box where I can check this out for you, so here are some
other things to check:

1. Make sure that SR-2 has been applied to all of Office 97, not just
Access 97. This is because the FileSearch object is a part of Office, not
Access, and you will want to be sure that the Microsoft Office 8.0 Object
Library is current.

2. Based on a search of the MS KB,
http://support.microsoft.com, searching
 
V

Vivek

Thanks Dev for the feedback.

Vivek

-----Original Message-----
[email protected]:

I am using Access 97. It's on SR - 2. I am trying this
on Windows NT Workstation.

If I'm not mistaken, FileSearch had some problems in Access 97 version. It
wasn't totally reliable. In some cases, Win2K SP2 fixed the problem, but
you're running Win NT.

Try searching groups.google.com for Dir$ samples (couple have been provided
in this newsgroup in the last week). Another option is to use the APIs
directly. See

[ http://www.mvps.org/access/modules/mdl0051.htm ]

-- Dev

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top