Results 1 to 7 of 7
  1. #1
    Cjtman is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Location
    MI
    Posts
    3

    Unhappy Search Function for External Files

    Hi all,
    I am creating a button on a form that opens a folder on our local network. This is what I currently have:

    Private Sub Command92_Click()
    Application.FollowHyperlink "N:\_BMP CAD\5000"
    End Sub

    I would like to add a file name to the end of this address, something like this:

    Private Sub Command92_Click()
    Application.FollowHyperlink "N:\_BMP CAD\5000\examplefile.prt"
    End Sub

    The catch is that I would like this file name to be dynamically pulled from a text box. Below is something like how I think this should look. The syntax is completely wrong, but it should get the point across.

    Private Sub Command92_Click()
    Application.FollowHyperlink "N:\_BMP CAD\5000\*[SearchBox]*"
    End Sub

    I would greatly appreciate more experienced input on this!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    this function already exists in the file explorer, top right corner box.

  3. #3
    Cjtman is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Location
    MI
    Posts
    3
    Could you expound on that statement? I didn't catch what you are referring to.

  4. #4
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Maybe try
    Code:
    Private Sub Command92_Click()
        Dim default
        Dim Title As String
        Dim prompt As String
    
        prompt = "Enter a file name"
        Title = "Get file name"
        Application.FollowHyperlink "N:\_BMP CAD\5000\*" & InputBox(prompt, Title, default) & "*"
    End Sub
    I NEVER use the InputBox function. I would have an unbound text box control on a form and get the value from the text box. Better yet, I would have a combo box so the file name could be selected first.

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    but the value is to come from a form textbox, no?

    Application.FollowHyperlink "N:\_BMP CAD\5000\" & Me.txtNameOfTextbox

    If the textbox provides an invalid value, you'll generate an error, which you're not trying to trap. Maybe you should use the msoFileDialogFilePicker control and forget the textbox idea.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    Cjtman is offline Novice
    Windows 10 Access 2016
    Join Date
    Dec 2017
    Location
    MI
    Posts
    3
    Thanks to all of you for your quick replies! Are there any suggestions about how I could open File explorer with a button and fill the search from the textbox content on the form?
    (BTW, I am not an experienced programmer- just somewhat basic stuff)

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Quote Originally Posted by Cjtman View Post
    Are there any suggestions about how I could open File explorer with a button...
    That was covered in post 5.
    Maybe you should use the msoFileDialogFilePicker control
    There are a gazillion sites with code solutions you can copy rather than us copying from anywhere and reposting it here. All you need to do is search. There is a folder picker and file picker version, so know what it is you want to navigate to - folder or file - before you start copying code.

    You also have been shown how to get the data from the text box and concatenate it to the beginning of your file path. You can use this information in your version of the code to pass the starting point to the picker dialog if you want to.

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

Similar Threads

  1. Linking External Files
    By denniston in forum Access
    Replies: 4
    Last Post: 12-15-2017, 07:23 PM
  2. uae external files
    By Jen0dorf in forum Access
    Replies: 7
    Last Post: 11-21-2015, 03:44 PM
  3. running Access function/code from external application
    By jan.simpson in forum Programming
    Replies: 8
    Last Post: 10-08-2015, 04:20 PM
  4. Link to external files
    By spacekowboy in forum Access
    Replies: 5
    Last Post: 06-08-2015, 08:09 PM
  5. Really need help with external excel files
    By zu3st3r in forum Import/Export Data
    Replies: 6
    Last Post: 02-04-2012, 02:48 AM

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