Results 1 to 6 of 6
  1. #1
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66

    Button to Browse for File!

    I have tried five or six different codes and each ahs given me an error.


    I am using Access 2010

    I have a form named "frmClass_File"
    I have a text box named "txtSelectedFile" which is set as a "Hyper Link"
    I have a text box named "txtFileName" which is set as normal txt

    I would like a button which would accomplish the following:

    1. Open browsing window.
    2. Allow user to find file (of any kind)
    3. When selected, place the file PATH in "txtSelectedFile" AND the file NAME in "txtFileName"

    Any help would be FANTASTIC!!!!

    Joe

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So I take it you have already tried this code: http://access.mvps.org/access/api/api0001.htm

  3. #3
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    I have been looking at that all morning and can't make anything of it.

    Here is where I am right now.
    I have the path going to the right place... now I need the name.
    I'm not sure if the path is being created as an actual click-able link or not.

    Code:
    Private Sub Command458_Click()
    
        Dim f As Object
        Dim strSelectedFile As String
        Dim txtFileName As String
        Dim varItem As Variant
    
        Set f = Application.FileDialog(3)
        f.AllowMultiSelect = False
        
        If f.Show = -1 Then
            For Each varItem In f.SelectedItems
                 strSelectedFile = varItem & "#" & varItem
                 Next varItem
                 Me![txtSelectedFile] = strSelectedFile
              
        End If
        Set f = Nothing
    
    End Sub

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I'm sorry but I use the API.

  5. #5
    floyd is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    66
    I got it!!!!
    Can you explain API? I have seen it talked about but have no idea what it is or how it works.

    Code:
    Private Sub Command458_Click()
    
        Dim f As Object
        Dim strSelectedpath As String
        Dim strSelectedFile As String
        Dim varItem As Variant
    
        Set f = Application.FileDialog(3)
        f.AllowMultiSelect = False
        
        If f.Show = -1 Then
            For Each varItem In f.SelectedItems
                 strSelectedpath = varItem & "#" & varItem
                 strSelectedFile = Split(strSelectedpath, "\")(UBound(Split(strSelectedpath, "\")))
                 Next varItem
                 Me![txtSelectedFile] = strSelectedpath
                 Me![txtFileName] = strSelectedFile
                 
        End If
        Set f = Nothing
    
    End Sub

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The API was described in the link I supplied. All of the code goes in a Standard Module and then you call it from your form.

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

Similar Threads

  1. Creating a Browse button to create a Hyperlink
    By detaylor1242 in forum Forms
    Replies: 5
    Last Post: 07-30-2013, 11:48 AM
  2. Link Pictures & Adding Browse Button
    By OldGreg134 in forum Access
    Replies: 1
    Last Post: 06-29-2012, 01:02 PM
  3. Browse for Excel File and Import
    By AKQTS in forum Programming
    Replies: 1
    Last Post: 07-12-2011, 07:33 AM
  4. Browse to external file while in a form
    By michaeljohnh in forum Import/Export Data
    Replies: 9
    Last Post: 09-22-2010, 09:33 AM
  5. Browse for file
    By ccpine@comcast.net in forum Database Design
    Replies: 0
    Last Post: 08-24-2008, 10:12 AM

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