Results 1 to 8 of 8
  1. #1
    tholden is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2020
    Posts
    14

    Creating a button to open a file by typing in file name from a specific folder

    I have a folder, in with consistant file name configurations are located, many files. Example: PN<space>Revision.PDF or 101456 A.pdf



    This file is always in a specific folder on our network. I would like there to be a button which when pressed opens the specific PDF after I type in the name, without having to type in the folder location (its long) \\server\FILESHARE\Public\Company Release Drawings\

    I looked around the forums for something similar, didnt have any luck so thought id post something new. Appreciate any help! Thanks!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can use FollowHyperlink. I'd have the base path either stored in a table or as a global constant. Then this type of thing:

    Application.FollowHyperlink gstrBasePath & Me.TextboxName

    using the applicable names.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    tholden is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2020
    Posts
    14
    Im sorry, im not a coder by any stretch, i looked in the macro action catalog for follow hyperlink but didnt see it anywhere.

    I tried plugging in the code as you out lined but im not sure how to point the code to the global constant, also not sure how to create a global constant

    Is the Me.Textboxname where the filename would be typed?

    And is the gstr<BasePath> where the hyperlink prefix is added? the \\server\FILESHARE\Public\Company Release Drawings\

    I have this so far
    Application.FollowHyperlink gstr & Me.search%pdf

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    This should help:

    https://docs.microsoft.com/en-us/off...ring-constants

    In my example gstrBasePath was a public constant containing the base path and TextboxName is the name of a textbox on the form where the user would type the file name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Oh, and as I don't use macros what I posted was VBA code.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    tholden is offline Novice
    Windows 10 Office 365
    Join Date
    Aug 2020
    Posts
    14
    I dont understand this help link on the constants, the code gives me errors as well when i try. Im sure what i have here is wrong, it gives me errors when i put try to use the "public string" line in the code..i am surely not a coder at all haha. any advice here?

    Option Compare Database


    Private Sub Command356_Click()
    Public String conAge As String =


    End Sub


    Private Sub List308_DblClick(Cancel As Integer)
    Application.FollowHyperlink \\server\FILESHARE\Public\QuadM%Release%Drawings & Me.search%pdf








    End Sub

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Let's make it more simple to start. Does the listbox you're clicking on contain the file name or something? Try this code:

    Code:
    Private Sub List308_DblClick(Cancel As Integer)
      Dim strBasePath As String
    
      strBasePath = "\\server\FILESHARE\Public\Company Release Drawings\"
      Application.FollowHyperlink  strBasePath & Me.List308
    
    End Sub
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,643

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

Similar Threads

  1. Open a file in a folder
    By LonghronJ in forum Modules
    Replies: 3
    Last Post: 04-29-2016, 02:39 PM
  2. Replies: 9
    Last Post: 02-18-2016, 10:38 AM
  3. Replies: 2
    Last Post: 10-29-2013, 09:31 AM
  4. Replies: 21
    Last Post: 08-20-2012, 11:59 PM
  5. Button to Open a Specific Folder
    By dnelms in forum Programming
    Replies: 1
    Last Post: 04-08-2011, 10:05 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