Results 1 to 10 of 10
  1. #1
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95

    On button click, find and open a file inside desired folder

    Hello everybody!



    I have one question; how can I make a Button to check for me a specific folder and open a PDF file inside it (if existing)?

    Thanks!
    Click image for larger version. 

Name:	On button click, find and open a file inside desired folder.jpg 
Views:	15 
Size:	156.3 KB 
ID:	23725

  2. #2
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Is the folder always the same or do you want a Open File Dialog to open and then you choose folder? Is file name always the same as REQUEST NO? And always .pdf?

  3. #3
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95
    Thanks for replying..

    I don't need a form to ask me to browse for folder. The folder path will be always the same and way of naming files is inside that folder will always be the same (like request number; 5-digits name...). In that folder I will have ONLY PDFs.

  4. #4
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Then I suggest using Allen Browne's functions to check if file exist and then use Application.FollowHyperlink to open it or display a label on form with note that it doesn't exist.

  5. #5
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95
    I was unable to solve it via Allen Brown's functions, but, this could be helpfull to me:

    Private Sub Label8_Click()
    If Len(Dir("C:\Users\azdajicv\Desktop\Web database\DAILY OVERVIEW OF CHECKED REPORTS\Requests\22556.pdf")) = 0 Then
    MsgBox "This file does NOT exist."
    Else
    MsgBox "This file does exist."
    End If
    End Sub

    This way I can see does the file exist in my folder and if it does, I can browse the folder manually and open the file inside it... As you can see above, the formula works only for 22556.pdf but I would like it to work for whichever request I put in REQUEST NO field. How can I do that?

  6. #6
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    I don't know what problems could you possibly have with Allen Browne's functions, all is explained in comments there. But anyway, if you'd like to follow this path:
    Code:
    Private Sub Label8_Click()
    Dim sFileName As String
        sFileName = "C:\Users\azdajicv\Desktop\Web database\DAILY OVERVIEW OF CHECKED REPORTS\Requests" & Me![REQUEST NO] & ".pdf"
        If Len(Dir(sFileName)) = 0 Then
            MsgBox "This file does NOT exist."
        Else
            Application.FollowHyperlink sFileName
        End If
    End Sub

  7. #7
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95
    Thanks for posting.. I am a beginner so I must have done something wrong with Mr. Brown's function...

    I have tried the way you told me but again I must have done something wrong.. Hm..

    Click image for larger version. 

Name:	Cannot confirm existence of existing PDF file.jpg 
Views:	13 
Size:	129.8 KB 
ID:	23726

  8. #8
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    Ah yes, sorry, backslash missing in path:
    sFileName = "C:\Users\azdajicv\Desktop\Web database\DAILY OVERVIEW OF CHECKED REPORTS\Requests\" & Me![REQUEST NO] & ".pdf"

  9. #9
    vazdajic is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2016
    Posts
    95
    Thank you so much! It works perfect!!

  10. #10
    cyanidem's Avatar
    cyanidem is offline Competent Performer
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2015
    Location
    Consett, UK
    Posts
    270
    You're welcome

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

Similar Threads

  1. Replies: 10
    Last Post: 09-09-2015, 03:25 AM
  2. Replies: 1
    Last Post: 08-21-2014, 02:29 PM
  3. Replies: 3
    Last Post: 02-22-2013, 06:41 AM
  4. Replies: 2
    Last Post: 05-25-2012, 07:36 AM
  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