Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72

    opening multiple files

    Good day. Our company must keep many client signed documents, which we store in PDF. My interface form has a field which is doubleclicked to bring up the corresponding document. All good, until there are multiple documents. The system stores these as the same filename with an extension of "-1" "-2" etc.

    Below is the code I use to open the single file. Any suggestions as to modifying or rewriting it to open the extension files as well would be greatly appreciated.

    Stephen



    begin code........................

    Private Sub ControlNumber_DblClick(Cancel As Integer)
    Dim TheFile As String
    Dim FileExt As String
    Dim thepath As String

    thepath = "Q:\Data\ServiceDatabase\worktickets\"
    TheFile = ControlNumber.value
    FileExt = ".pdf"

    Application.FollowHyperlink thepath & TheFile & FileExt
    End Sub

  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 if the Control Number is 111111 and the file is 111111.pdf, what would be the 2nd filename?

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    I'm assuming that you mean the -1 or -2 is part of the filename, rather than replacing the .pdf extension. (myname-1.pdf rather than myname.-1 or myname.pdf.-1)
    Code:
    Private Sub ControlNumber_DblClick(Cancel As Integer)
    Dim TheFile As String
    Dim TheNumber As String
    Dim FileExt As String
    Dim thepath As String
    thepath = "Q:\Data\ServiceDatabase\worktickets\"
    TheFile = ControlNumber.value
    TheNumber = "-" & {{{{This is where you code which of the files you want to get... 1, 2, 3 etc}}}}}
    FileExt = ".pdf"
    Application.FollowHyperlink thepath & TheFile & TheNumber & FileExt
    End Sub

  4. #4
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72
    The "-x" extension will add to the filename, not the .pdf. So it will be 1111.pdf; 1111-1.pdf; 1111-2.pdf, etc. An unknown quantity of extensions, no more than 4 or 5, but as shown in this example there could be NO "-x" as well.

  5. #5
    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
    Do you want to open all of them at the same time or one at a time? Can you take it from here with what Dal supplied or would you like some additional code?

  6. #6
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72
    I'd like to open all at once. The code makes sense, I have to figure out how to loop through, and end the loop, if there is or is not a -x. Any help would be great. Unfortunately, I'm an electrician and not a programmer, but I'm learning....

    Thanks,
    Stephen.

  7. #7
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Is your user really going to want to always open every PDF associated with the account? Or is this the time to create a small table that gives a short description of each document, so they can choose the right one?

  8. #8
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72
    Actually, the need is to open all. This is an invoicing function, and the documents are field drawings, etc that must be reviewed to determine invoicing amounts. Typically, there are 1 or two. Sometimes there are more, but that is rare.

    Stephen.

  9. #9
    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
    Give this a try. I expanded Dal's code a bit but it is UNTESTED!
    Code:
    Private Sub ControlNumber_DblClick(Cancel As Integer)
       Dim TheFile As String
       Dim TheNumber As String
       Dim FileExt As String
       Dim thepath As String
       Dim LoopCounter As Integer
       LoopCounter = 0
       Dim Looping As Boolean
       Looping = True
       thepath = "Q:\Data\ServiceDatabase\worktickets\"
       TheFile = ControlNumber.Value
       FileExt = ".pdf"
       TheNumber = ""
       Do While Dir(thepath & TheFile & TheNumber & FileExt) <> ""
          Application.FollowHyperlink thepath & TheFile & TheNumber & FileExt
          LoopCounter = LoopCounter + 1
          TheFile = Me.ControlNumber & "-" & LoopCounter
       Loop
    End Sub

  10. #10
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Minor modification in red.
    Code:
       TheNumber = ""
       Do While Dir(thepath & TheFile & TheNumber & FileExt) <> ""
          Application.FollowHyperlink thepath & TheFile & TheNumber & FileExt
          LoopCounter = LoopCounter + 1
          TheNumber = "-" & LoopCounter
      Loop
    End Sub

  11. #11
    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
    Oops! Thanks Dal.

  12. #12
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72
    Awesome, guys. I'm away until Sunday, but will try it, and report as solved once I can confirm. Many, many thanks.

  13. #13
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Your way would have worked, I think, but TheNumber would have been redundant. This fix changed less lines.

  14. #14
    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
    It is what I had intended to do. I just lost track of which variable I was changing. Getting old sucks. Happy New Year btw.

  15. #15
    stephenaa5 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Oct 2009
    Posts
    72
    I finally got a chance to implement this. It worked like a charm. Thank you, guys.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Opening files from extranet site
    By Ashe in forum Programming
    Replies: 1
    Last Post: 03-06-2013, 12:59 PM
  2. Opening .mdb files under Windows 7
    By GeoffGreen in forum Access
    Replies: 1
    Last Post: 08-08-2012, 04:18 PM
  3. Replies: 4
    Last Post: 06-14-2011, 07:19 PM
  4. Replies: 2
    Last Post: 05-25-2010, 02:45 PM
  5. Importing multiple files at once
    By NoiCe in forum Import/Export Data
    Replies: 1
    Last Post: 04-01-2009, 10:10 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