Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    20

    Unanswered: Hyperlinks don't work

    Howdy,
    My database creates a path to a folder depending on some user inputs. The path is saved as a hyperlink.
    These hyperlinks are shown on a form. When the user clicks the hyperlink I would like the file dialog box to open, starting in the folder specified by the hyperlink.
    Any ideas? I guess I put some code on the 'On Click' event property.

    Thanks in advance for any help you can give me with this!

    Thanks

    Dave

  2. #2
    Join Date
    Nov 2003
    Location
    LONDON
    Posts
    238
    If you are using Access XP/2003 then you can use the Application.FileDialog object to open a file dialog at the folder specified. See help for the full syntax of the object.

    Justin

  3. #3
    Join Date
    Jan 2005
    Posts
    20

    Unhappy

    Thanks
    Using 2002
    Will look in to the FileDialog thing though,
    Does anyone have a little bit of code they may have used before??

  4. #4
    Join Date
    Feb 2005
    Posts
    333
    Here is something I've used in the past in 2000. I can't take credit, found it on the web.

    Paste the following code in a module and call the function from your form using something like: selectFile "Select PSR to Import", "txt"

    Code:
    Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
    "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
    
    Private Type OPENFILENAME
        lStructSize As Long
        hwndOwner As Long
        hInstance As Long
        lpstrFilter As String
        lpstrCustomFilter As String
        nMaxCustFilter As Long
        nFilterIndex As Long
        lpstrFile As String
        nMaxFile As Long
        lpstrFileTitle As String
        nMaxFileTitle As Long
        lpstrInitialDir As String
        lpstrTitle As String
        flags As Long
        nFileOffset As Integer
        nFileExtension As Integer
        lpstrDefExt As String
        lCustData As Long
        lpfnHook As Long
        lpTemplateName As String
    End Type
    
    Public Function selectFile(mytitle, filetype)
        Dim OpenFile As OPENFILENAME
        Dim sFilter As String
        Dim defLoc As String
          
        defLoc = "G:\TRFRS\PRMMS\0820R36.RSR" 'where to start from
        OpenFile.lStructSize = Len(OpenFile)
        OpenFile.hwndOwner = hWinLoc
        OpenFile.hInstance = -1 'use for Visual Basic for Applications
        
        ' chr(0) represents a null character
        
        If filetype = "txt" Then
            sFilter = sFilter & "Text files (*.txt)" & Chr(0) & "*.txt" & Chr(0)  'start the string
            sFilter = sFilter & "Excel files (*.xls)" & Chr(0) & "*.xls" & Chr(0)
        ElseIf filetype = "exl" Then
            sFilter = sFilter & "Excel files (*.xls)" & Chr(0) & "*.xls" & Chr(0)
            sFilter = sFilter & "Text files (*.txt)" & Chr(0) & "*.txt" & Chr(0)
        End If
            
        sFilter = sFilter & "All files (*.*)" & Chr(0) & "*.*" 'Add something that allows all files to be seen
    
        OpenFile.lpstrFilter = sFilter
        OpenFile.nFilterIndex = 1
        OpenFile.lpstrFile = String(257, 0) 'generate a string of 257 null characters.
        OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1 '  max length of filename
        OpenFile.lpstrFileTitle = OpenFile.lpstrFile
        OpenFile.nMaxFileTitle = OpenFile.nMaxFile
        OpenFile.lpstrInitialDir = defLoc
        ' change "mytitle" above to change the title on your open dialog box
        OpenFile.lpstrTitle = mytitle
        OpenFile.flags = 0
        lreturn = GetOpenFileName(OpenFile)
        If lreturn = 0 Then
           'MsgBox "The User pressed the Cancel Button"
            FILESELECT = ""
        Else
            ' returns a copy of the filename without leading or trailing spaces
            FILESELECT = Trim(OpenFile.lpstrFile)
            
            'returns a copy of the filename without trailing spaces or null characters
            If InStr(FILESELECT, Chr(0)) > 0 Then
                FILESELECT = Left(FILESELECT, InStr(FILESELECT, Chr(0)) - 1)
            End If
        End If
    
    End Function

Posting Permissions

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