Filesearch

B

Ben dotNet

I am using the Application.Filesearch to look for the existence of a file.
if I find it, I render it in an image box.
the problem is this (I think);
I look for file "568.jpg". the Filesearch finds file "1568.jpg" and thinks
its got a match. I want an EXACT match only.
Is there a way?
Here's my code.

With fs
.NewSearch
.LookIn = DrawingsPath
.FileName = Me!CompID & ".jpg"
.MatchTextExactly = True
If .Execute > 0 Then
Me!Drawing1.Picture = DrawingsPath & "\" & Me!CompID & ".jpg"
Else
Me!Drawing1.Picture = ""
End If
End With
 
T

Tom Ogilvy

With fs
.NewSearch
.LookIn = DrawingsPath
.FileName = Me!CompID & ".jpg"
.MatchTextExactly = True ' doesn't have anything to do with file names
If .Execute > 0 Then
for i = 1 to .foundfiles
if Ucase(DrawingsPath & "\" & Me!CompID & ".jpg") = _
.foundFiles(i) then

Me!Drawing1.Picture = DrawingsPath & "\" & Me!CompID & ".jpg"
Exit For
end if
Next
Else
Me!Drawing1.Picture = ""
End If
End With
 

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