Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Manchester, Gtr Manchester, England
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Create a button to browse for files

    How can I create a button on an Access form that will open a browse for file dialog?
    I then need the chosen file path to be inserted into a hyperlink field.

  2. Subscribe to our Windows Secrets Newsletter - It's Free!

    Get our unique weekly Newsletter with tips and techniques, how to's and critical updates on Windows 7, Windows 8, Windows XP, Firefox, Internet Explorer, Google, etc. Join our 480,000 subscribers!

    Excel 2013: The Missing Manual

    + Get this BONUS — free!

    Get the most of Excel! Learn about new features, basics of creating a new spreadsheet and using the infamous Ribbon in the first chapter of Excel 2013: The Missing Manual - Subscribe and download Chapter 1 for free!

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

    Re: Create a button to browse for files

    Sorry, but the only way to use the open file dialog is either to use a direct call to the Windows CommonDialog through the WinAPI or to use the CommonDialog control. There really isn't any easy way to do it in the current versions of Access.
    Charlotte

  4. #3
    New Lounger
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Create a button to browse for files

    <pre>Private Sub Command0_Click()
    '<font color=448800>
    'I would not consider this to be "easy", so Charlotte's comment is valid. But here's
    ' a way to do it.

    'You need a reference set to Excel for this to work.
    '</font color=448800>
    Dim xl As Excel.Application
    Dim str
    '<font color=448800>
    'A new instance of excel will open
    '</font color=448800>
    Set xl = New Excel.Application
    '<font color=448800>
    'It has to be visible for the Dialogue to appear
    '</font color=448800>
    xl.Visible = True

    '<font color=448800>
    'Excel's GetOpenFilename method returns a string of the path and file name you select.
    ' If you do not select a file, it returns "False"
    '</font color=448800>
    str = xl.GetOpenFilename()
    MsgBox str

    '<font color=448800>
    'Be sure to quit excel or it will continue to run in the background.
    '</font color=448800>
    xl.Quit
    Set xl = Nothing

    '<font color=448800>
    'Hope this helps!
    '</font color=448800>

    End Sub
    </pre>


  5. #4
    Star Lounger
    Join Date
    Apr 2002
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Try the Code at This Site

    http://www.mvps.org/access/api/api0001.htm

    Code courtesy of:' Microsoft Access 95 How-To' Ken Getz and Paul Litwin
    ' Waite Group Press, 1996

    It has code for an API call that has, thus far, worked great for my application.

    Good luck.

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

    Re: Create a button to browse for files

    Nice workaround! I use a class based on the WinAPI, but on a machine with adequate resources, this should work without the headaches of API calls. I'll have to try it sometime.
    Charlotte

  7. #6
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,510
    Thanks
    3
    Thanked 143 Times in 136 Posts

    Re: Create a button to browse for files

    <P ID="edit"><FONT SIZE=-1>Edited by charlotte on 01/01/10 03:52.</FONT></P>I changed your addresses to hyperlinks. Click on!--Charlotte

    I also agree with Charlotte's not easy comment. The most useful demonstration I have seen is in a Candace Tripp demo database called Backup Database (130Kb download) at ftp://www.athree.com/pub/candace/can...ckup/bkup2.zip - Access2 version
    ftp://www.athree.com/pub/candace/can...kup/bkup97.zip - Access97 version

    There is a whole lot more than what you are requiring but it can be built from selected components in that file.

    Have a look at the site where it all sits for all sorts of useful downloads
    http://www.candace-tripp.com/_pages/...fault_HTML.htm

    The hyperlinking is a simple one liner once you have the string containing the path to the file. An example is shown below
    Me.lblFldr.HyperlinkAddress = PthNam
    where Me.lblFldr is the name of the control which is hyperlinked and PthNam is the string to it.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

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