Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Code problems (Access 2000)

    I copied this code from The Access Web and am trying to run it but I seem to be stumbling on the line <font color=blue>If .Execute >0 Then</font color=blue> It never returns a value for .Execute > 0. If I change it to > = 0 then it runs till the next line then bombs. Anyone use this or something like it. I'm trying to create a work around for the Windows Explorer Find Dialog Box. Thanks
    Paul

    Function fReturnFilePath(strFilename As String, _
    strDrive As String) As String

    Dim varItm As Variant
    Dim strFiles As String
    Dim strTmp As String

    If InStr(strFilename, ".") = 0 Then
    MsgBox "Sorry!! Need the complete name", vbCritical
    Exit Function
    End If

    strFiles = ""
    With Application.FileSearch
    .NewSearch
    .LookIn = strDrive
    .SearchSubFolders = True
    .FileName = strFilename
    .MatchTextExactly = True
    .FileType = msoFileTypeAllFiles
    If .Execute > 0 Then
    For Each varItm In .FoundFiles
    strTmp = fGetFileName(varItm)
    If strFilename = strTmp Then
    fReturnFilePath = varItm
    Exit Function
    End If
    Next varItm
    End If
    End With
    End Function

    Private Function fGetFileName(strFullPath) As String
    Dim intPos As Integer, intLen As Integer
    intLen = Len(strFullPath)
    If intLen Then
    For intPos = intLen To 1 Step -1
    'Find the last
    If Mid$(strFullPath, intPos, 1) = "" Then
    fGetFileName = Mid$(strFullPath, intPos + 1)
    Exit Function
    End If
    Next intPos
    End If
    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Code problems (Access 2000)

    Just a thought. What happens if you change this:

    .Execute > 0

    to this:

    .Execute() > 0

    I know they should evaluate the same way, but I seem to recall having a problem like this with the Execute method of the FileSearch object.
    Charlotte

  3. #3
    Star Lounger
    Join Date
    Oct 2001
    Location
    Western Massachusetts, USA
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Code problems (Access 2000)

    Thanks, that was it. I don't know how many decades it would have taken me to figure that one out.
    Paul

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •