Results 1 to 6 of 6
  1. #1
    detaylor1242 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Lacey, WA
    Posts
    19

    Creating a Browse button to create a Hyperlink


    I have two fields (hyperlink) that I would like to add a browse button to so that I can find the file and then put that link into the field. Any suggestions or code appreciated..

  2. #2
    mike02 is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    245
    I use this code here:

    Code:
    Private Function GETDIR()
      Dim mybrowse As BROWSEINFO
      Dim Mydirectory As String
      
        Dim path As String
        Dim R As Long, X As Long, pos As Integer
        
        mybrowse.pidlRoot = 0&
    
    
    '************************************************************************************************
    '0 'Desktop is the root directory. With BIF_returnonlyfsdirs circumvents problem with OK-button *
    '1 'Internet Explorer is the root                                                               *
    '2 'Programs folder of the start menu is the root                                               *
    '3 'Control Panel is the root. Needs BIF_browseincludefiles                                     *
    '4 'Printers folder is the root. Needs BIF_browseincludefiles                                   *
    '5 'Documentsfolder is the root                                                                 *
    '6 'Favorites is the root                                                                       *
    '7 'Startup-folder of the startmenu is the root. Needs BIF_browseincludefiles                   *
    '8  'Recentfolder is the root. Needs BIF_browseincludefiles                                     *
    '9 'Sendto-folder is the root. Needs BIF_browseincludefiles                                     *
    '10 'Recycle Bin is the root. Needs BIF_browseincludefiles                                      *
    '11 'Start Menu is the root                                                                     *
    '16 'The Desktopdirectory is the root directory                                                 *
    '17 'The drives (My computer) folder is the root                                                *
    '18 'The networkneighbourhood is the root                                                       *
    '19 'The nethoodfolder is the root                                                              *
    '20 'The fontsfolder is the root                                                                *
    '21 'The templatesfolder is the root                                                            *
    '************************************************************************************************
      
            mybrowse.lpszTitle = "SELECT A DIRECTORY"
       
        mybrowse.ulFlags = &H1 '(H4000 RETURNS FILENAME)
    
    
        X = SHBrowseForFolder(mybrowse)
        
        path = Space$(512)
        R = SHGetPathFromIDList(ByVal X, ByVal path)
        If R Then
            pos = InStr(path, Chr$(0))
            Mydirectory = Left(path, pos - 1)
            
            Me.txtoutputdirectory.value = Mydirectory
            
                
    End If
    End Function
    Me.txtoutputdirectory.value = Mydirectory
    Puts the value in the text box. I called my text box txtoutputdirectory

    Then on the button, run a command.
    Code:
    Call GETDIR
    Hope this helps,

  3. #3
    detaylor1242 is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Lacey, WA
    Posts
    19
    This looks like what I need but I am not sure how to implement it. I have not done any coding within a database so am not sure how to get this into my project? Thanks in advance for your support.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    I expect the Function code should be placed in the code module behind the form. Try copy/paste from the post. Modify the code for your textbox name. Then in the button Click event trigger the function with: GetDir()

    Google: Access introduction to programming

    http://office.microsoft.com/en-001/a...010341717.aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    swavemeisterg is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2012
    Posts
    28
    I tried running your code and got a "Compile Error: User-defined type not defined." Any idea why this is happening?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Sounds like need to set a library reference in VBA. I have no idea which one is relevant to Mike's code. Or maybe define the type programmatically. Review: http://www.developerfusion.com/code/...or-folder-vba/
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. creating Automatic Hyperlink
    By zachir in forum Forms
    Replies: 1
    Last Post: 04-22-2013, 12:51 PM
  2. Create Hyperlink and send via email
    By tcheck in forum Access
    Replies: 7
    Last Post: 11-20-2012, 06:24 PM
  3. Creating Browse function in Access 2010
    By martindenise in forum Access
    Replies: 3
    Last Post: 08-09-2012, 05:44 PM
  4. Link Pictures & Adding Browse Button
    By OldGreg134 in forum Access
    Replies: 1
    Last Post: 06-29-2012, 01:02 PM
  5. Creating a Hyperlink
    By dwmackay in forum Forms
    Replies: 1
    Last Post: 09-11-2011, 06:58 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums