Results 1 to 6 of 6
  1. #1
    MarcieFess is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    9

    Question Trimming Hyperlink Path to PDF Documents to Just Document Name & displaying In Report

    I have PDF documents attached to records. Well, the hyperlinks to their location on the server is actually in the records.

    I have a query that gets DISTINCT records for a particular store from user input in a form. The output looks like this:

    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\ACETONE.pdf
    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\ACNE EXFOLIATING PADS.pdf
    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Almond Oil.pdf
    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Bain De Terre Infinite Hold Spray.pdf
    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Batiste Dry Shampoo.pdf
    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Canola Oil.pdf
    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Coconut Oil.pdf
    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\Coppertone Sunscreen Sprays.pdf

    That's fine for the first report.

    For a second report, I need to trim the first 58 characters from the hyperlink. I figured I'd use



    Mid([qryMSDSPrint.MSDS] As String, 59 As Number) As String

    to do that. Is that correct?

    I want my final report to look like this:

    Store # Store Name
    MATERIAL SAFETY DATA SHEETS
    TABLE OF CONTENTS
    A

    ACETONE.pdf
    ACNE EXFOLIATING PADS.pdf
    Almond Oil.pdf

    next page

    Store # Store Name
    MATERIAL SAFETY DATA SHEETS
    TABLE OF CONTENTS
    B

    Bain De Terre Infinite Hold Spray.pdf
    Batiste Dry Shampoo.pdf


    Next page


    Store # Store Name
    MATERIAL SAFETY DATA SHEETS
    TABLE OF CONTENTS
    C

    Canola Oil.pdf
    Coconut Oil.pdf
    Coppertone Sunscreen Sprays.pdf


    I already have the page header set up for everything except the letter of the alphabet for that page.

    I imagine I would use the LEFT function to get the letter of the alphabet for each page.

    My issue is, I am really, really green at reports. When it comes to limiting a report using VBA, functions, etc. I don't even know where to begin.

    The end result of all of this will be that someone will manually print all of the PDFs. The procedure I'm working on now will print out a cover page for each letter of the alphabet, kind of like using a TOC but not really. It needs to be alphabetized by the name of each document.

    If it helps, here's my code for the button so far:

    Code:
    '------------------------------------------------------------' btnMSDSSheetsPrint_Click
    '
    '------------------------------------------------------------
    Private Sub btnMSDSSheetsPrint_Click()
    On Error GoTo btnMSDSSheetsPrint_Click_Err
    
    
    
    
    If IsNull(Me.cboCompany) Then
        MsgBox ("Choose a Company!")
        Me.cboCompany.SetFocus
        Exit Sub
    End If
    
    
    If IsNull(Me.cboStore) Then
        MsgBox ("Choose a Store!")
        Me.cboStore.SetFocus
        Exit Sub
    End If
    
    
        DoCmd.OpenQuery "qryMSDSPrint"
            
        DoCmd.OpenReport ("rptMSDSTblOfCntnts")
        
          
        
    ExitS:
        DoCmd.Echo True
        Exit Sub
        
    btnMSDSSheetsPrint_Click_Exit:
        Exit Sub
    
    
    btnMSDSSheetsPrint_Click_Err:
        If Err.Number = 2501 Then
      MsgBox ("No records exist for this store/company!")
    Else
    MsgBox Error$
    End If
        Resume btnMSDSSheetsPrint_Click_Exit
    
    
    End Sub


    The line I put in red above is the line that will run the report that I'm trying to format right now.

    Thanks, everyone, for your help. I truly appreciate it.

    Marcie

  2. #2
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    You do not have to open the query to open the report based on it. You will need an additional field in the query Left("YourFileName",1) for alphabet list. Then in the report, you need to use "Group and Sort" (Design >Group & Sort) to group the results based on alphabet field and use the option to "keep whole group together on page" so that each alphabet starts on new page.This alphabet field should be in the "Group Header".

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    The pdf file path is stored in a hyperlink type field? Don't need the string functions to break up a hyperlink. Review:
    http://msdn.microsoft.com/en-us/libr.../ff844740.aspx

    If the link is just a string in a text field, then use intrinsic string functions.
    Mid([MSDS], 59)


    Also of interest.
    http://www.allenbrowne.com/casu-09.html
    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.

  4. #4
    MarcieFess is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    9

    Thank you Amrut - one more question please

    Thank you, Amrut. With a little tweaking, what you said worked for me!

    One more question.

    My query is:

    Code:
    SELECT DISTINCT Mid([Product.MSDS],59) AS MSDS, tblStoreInformation.StoreNum, tblStoreProducts.StoreKey, Left([MSDS],1) AS Alph
    FROM tblStoreInformation INNER JOIN (Product INNER JOIN tblStoreProducts ON Product.[ProductKey] = tblStoreProducts.[ProductKey]) ON tblStoreInformation.StoreKey = tblStoreProducts.StoreKey
    
    WHERE (((tblStoreProducts.MaxUnits)<>0) AND (([Product.HazardKey])<>79))
    
    GROUP BY Mid([Product.MSDS],59), tblStoreInformation.StoreNum, tblStoreProducts.StoreKey, Left([MSDS],1)
    
    HAVING (((Mid([Product.MSDS],59)) Is Not Null) AND ((tblStoreProducts.StoreKey)=[Forms]![frmChooseStore].[cboStore]));
    So now, instead of returning

    \\WESERVER\Data2\Projects\Projects\Access DB Project\MSDS\ACETONE.pdf
    it's now returning

    ACETONE.pdf#\\WESERVER\Data2\Projects\Projects\Acc ess DB Project\MSDS\ACETONE.pdf#
    Why did it just take the beginning 58 letters and stick them on the end wrapped in # ?

    I need it to actually truncate, not just move it around like that. I don't want to see anything between the '#'.

    How do I do that?

    If I solve this, the report is finished except for grouping one letter per page.

    Marcie

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    Did you read my post and review the links referenced?
    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.

  6. #6
    MarcieFess is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    9

    Trimming Hyperlink Path to PDF Documents

    Quote Originally Posted by June7 View Post
    Did you read my post and review the links referenced?
    Actually I did review the links. I'd posted that second question before your first response came through. It was perfect, thank you. The issue is solved!



    Marcie

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

Similar Threads

  1. Need to view linked document in report
    By dagwood in forum Reports
    Replies: 4
    Last Post: 05-09-2013, 07:27 AM
  2. Replies: 4
    Last Post: 06-04-2012, 11:09 AM
  3. PLEASE HELP Send Report to MkDir Path
    By alyon in forum Access
    Replies: 17
    Last Post: 12-06-2011, 05:56 PM
  4. Need Help Trimming Field!!
    By emarchant in forum Programming
    Replies: 7
    Last Post: 12-07-2010, 09:48 AM
  5. Set "My Documents" Path
    By jhrBanker in forum Programming
    Replies: 6
    Last Post: 05-25-2010, 07:42 PM

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