Results 1 to 7 of 7
  1. #1
    justgeig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    45

    Opening pdf from a calculated field

    I have a calculated field in a query "Advertiser Lookup" that calculates the correct path to open a PDF that each ad was placed on. It works wonderfully and correctly displays each path for each ad (in text form). The problem is that I would like to allow my users to click a button in a form OR click the path within the query as a hyperlink. Either way would be fine and maybe it would be nice to have both options. In case anyone is wondering about what is in the calculated field, here it is.

    Code:
    PathToPDF: "R:\Peoples Back ups\" & Year(Year([Issue Date]) & " " & IIf(Month([Issue Date])<10,"0" & Month([Issue Date]),Month([Issue Date])) & " " & IIf(Day([Issue Date])<10,"0" & Day([Issue Date]),Day([Issue Date]))) & "\" & (Year([Issue Date]) & " " & IIf(Month([Issue Date])<10,"0" & Month([Issue Date]),Month([Issue Date])) & " " & IIf(Day([Issue Date])<10,"0" & Day([Issue Date]),Day([Issue Date]))) & " Folder\PDFs\" & (Year([Issue Date]) & " " & IIf(Month([Issue Date])<10,"0" & Month([Issue Date]),Month([Issue Date])) & " " & IIf(Day([Issue Date])<10,"0" & Day([Issue Date]),Day([Issue Date]))) & " " & [Page] & ".pdf"
    and an example of the output is...

    R:\Peoples Back ups\2010\2010 04 08 Folder\PDFs\2010 04 08 42.pdf

    If I copy the output of the calculated field into Windows Explorer, it works perfectly. I even copied it into a test field that was set up as a hyperlink style and clicking it worked perfectly

    Any suggestions as to how I can accomplish this? I'm not so hot with VBA so I bet that's what I need to do lol

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Don't have spaces in the filename. Use underscores and adjust your code accordingly.

  3. #3
    justgeig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    45
    Hi orange:

    thanks for the reply. The code is working great though and is generating the correct file path. I want to know how to make a button on a form use that file path to open the pdf.

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    In the click event of your button you would have code

    ....
    Application.FollowHyperlink yourCalculatedFileHere

  5. #5
    justgeig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    45
    That did the trick :-) I can't believe how simple that was lol Thanks a bunch!

    As for the query, is there a way to make a calculated field into a hyperlink so that it can be clicked from there as well?

  6. #6
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    I'm not aware of a technique to do this from calculated field in a query. Normally, you allow the user to interact with the system via forms. So a button, properly named on a form, should do the trick.

  7. #7
    justgeig is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Dec 2009
    Posts
    45
    that's what I was afraid of, thank you so much for your help.

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

Similar Threads

  1. Calculated field help
    By eds in forum Access
    Replies: 2
    Last Post: 07-18-2011, 05:33 PM
  2. Calculated Field (if/then) Help
    By agent- in forum Programming
    Replies: 10
    Last Post: 03-30-2011, 05:43 PM
  3. calculated field
    By nashr1928 in forum Forms
    Replies: 2
    Last Post: 03-30-2011, 04:29 PM
  4. Calculated Field Help
    By Alex Motilal in forum Queries
    Replies: 2
    Last Post: 01-06-2011, 04:54 AM
  5. calculated field from calculated field?
    By RedGoneWILD in forum Reports
    Replies: 5
    Last Post: 08-03-2010, 02:32 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