Results 1 to 11 of 11
  1. #1
    Pommetje77 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    the Netherlands
    Posts
    37

    Post Search for specific .pdf file at server location and list in listbox

    Hello,
    I am a newbie on ms access forum.net

    I would like to have the VBA script for searching for a specific .pdf file on server location and list this (or multiple revisions of this file) in a list box on my form.
    The filled list box shall list the .pdf files and the files needs to be opened by double click.

    I do have an example script for adding all files from specific location to the list box, however I am struggling with adding search criteria.

    So far I have a form with text box 'drawing location' (which specifies the location of all the .pdf drawings on the server), I am having a text box with drawing number, which shall be the search criteria.
    The search criteria shall be based on the first 7 digits of the .pdf name.
    There is even a list box on the form where the found .pdf files need to be shown.
    It is not important it the script shall be activated by button click or form 'on current' event.
    It would be the easiest way to have it done with a function call I believe.

    I am using MS Access 2010, 64 bit with Windows 7 professional.



    Your help is highly appreciated

    thanks in advanced
    Ruud

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    For code to list files, review http://www.allenbrowne.com/ser-59.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Pommetje77 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    the Netherlands
    Posts
    37
    June7, thanks for your reply!
    However listing files in a list box is not a big deal.
    My problem is searching files according criteria and list the results of the search in a list box.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I expect Allen's code could handle that.

    Call ListFiles("drive:\folderpath", Left(Me.Number,7) & "*.pdf")
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Pommetje77 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    the Netherlands
    Posts
    37
    I will dig into this coming Friday, I am on business trip the next few days!
    Will let you know!

  6. #6
    Pommetje77 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    the Netherlands
    Posts
    37
    Hello June7,
    I have enclosed the database with Allen's code. It gives me all the files in the list box.
    With your 'call List files' method, it will not give me any information.
    It would be very nice if you can have a look and try to get it work in according with the text below.

    Again shortly, what the script should do:
    Show all the drawings available in the list box, in reference to the drawing number on the form
    The search criteria shall be the first 7 digits of the actual files. All the files are named like 6001002 ISS A, 6001003 ISS C, etc.
    I don't want to see the path of the location in the list box, only the numbers with Iss A, B etc.
    The found files in the list box shall be clickable, so they open with adobe reader or some other program.



    Attached Files Attached Files

  7. #7
    Pommetje77 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    the Netherlands
    Posts
    37
    Small correction now
    I've got it working with the following call function:

    Call ListFiles("C:\Documents\Drawings\pdf", Left(Me.PartNumber, 7) & "*.pdf", True, Me.lstFileList)

    The only thing is, I don't want to see the complete file path and it is still not clickable!

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    If you don't want the complete file path, modify code in FillDir function:

    colDirList.Add strTemp

    What do you mean by 'it is still not clickable'? What is not clickable - the listbox? There is no code behind the listbox. What do you want - to open the PDF when item in listbox selected? Need code in the listbox Click or AfterUpdate event. Review: http://allenbrowne.com/func-GoHyperlink.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    Pommetje77 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    the Netherlands
    Posts
    37
    Thanks for your help so far!
    So far I have drawing numbers only in my list box!

    I indeed want to open the selected .pdf file in the list box to open.
    I added the Allen Browne code 'GoHyperlink' including the double click event. However it gives me Error Number 490 (cannot open the specified file).
    If I modify the code a bit, I can get it to open the drawing directory, but the pdf won't open unfortunately!

    Call GoHyperlink(CurDir & "C:\Documents\Drawings\pdf") gives me Error Number 490 (cannot open the file)

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Well, if you use CurDir then can't specify C:\ drive & path. Also, there is no filename in that string.

    Call GoHyperlink("C:\Documents\Drawings\pdf\" & Me.comboboxname)

    Refer to link at bottom of my post for debugging guidelines.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    Pommetje77 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2015
    Location
    the Netherlands
    Posts
    37
    June7, Thank you for your support!
    Everything is working!

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

Similar Threads

  1. VBA to transfer a file from one location to another
    By Demerit in forum Programming
    Replies: 2
    Last Post: 09-21-2014, 02:58 PM
  2. Replies: 3
    Last Post: 06-11-2014, 01:25 PM
  3. Exporting Report to PDF specific location on quit - over-writing existing
    By augcorv@gmail.com in forum Import/Export Data
    Replies: 13
    Last Post: 03-21-2014, 02:08 PM
  4. Replies: 7
    Last Post: 02-01-2013, 02:58 PM
  5. File Location
    By Mitch87 in forum Programming
    Replies: 1
    Last Post: 02-19-2010, 11: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