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