• Code problems (Access 2000)

    Author
    Topic
    #363682

    I copied this code from The Access Web and am trying to run it but I seem to be stumbling on the line If .Execute >0 Then 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

    Viewing 0 reply threads
    Author
    Replies
    • #555767

      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.

      • #555782

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

    Viewing 0 reply threads
    Reply To: Code problems (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: