View Full Version : Issue with Filesearch (tried searching!)


mattkorguk
04-02-2008, 03:23 AM
I've tried searching on FileSearch, found a few thing but nothing which showed if it's possible to refer to a table instead of just placing "C:\My Documents" or similar into the .Lookin section.
We have a table [tblScanning] with holds only 1 entry, this is a path, and the one I'd like to refer to in the Filesearch .Lookin.
I keep receiving a Type mismatch on this...I'm sure I must be doing something wrong!

If (Not IsNull([Mtg Id])) Then
Dim db As Database
Dim First As Recordset
Set db = CurrentDb()
Set First = db.OpenRecordset([Table].[tblScanning].[Scan-Path])
First.MoveFirst
With Application.FileSearch
.NewSearch
.LookIn = First & Me.Case_Id
.FileName = "*Fee Agreement*"
If .Execute > 0 Then
Me.FeeAgreement = True
Else
Me.FeeAgreement = False
End If
End With
Else
Me.FeeAgreement = False
End If

Thank you.

mattkorguk
04-02-2008, 06:59 AM
Just thought I'd post the way I found out how to do it...used a hidden form with the details required, this seems to work fine. It then displays a count of the documents found that match the criteria. :)

Dim varItem As Variant
Dim Location As String

Location = [Forms]![frmMortgage-Details-Loan]![frmScanPath-Hidden]![Scan-Path] & "\" & Me.Case_Id
StrListItems = "'"
With Application.FileSearch
.NewSearch
.FileName = "*Fee Agreement*"
.LookIn = Location
.Execute
DoCmd.SetWarnings False

For Each varItem In .FoundFiles
Me.FeeAgreement = .FoundFiles.Count
Next varItem
End With