Results 1 to 10 of 10
  1. #1
    Hank153 is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2012
    Posts
    19

    Command Button on Report

    I have a report based on a query. The query has a ole bound object that is referred to as FamilyFile1. I want to put a command button on my report that will open FamilyFile1. This is normally a PDF file - but sometimes a word file. I have found code on how to open files with a command button, but none on how to open a different file for each report.

    Can someone give me the on click event code that will open the file?


    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,849
    If you really have 2003 you can't click on a button anyway. 2007 introduced Report view, which is interactive. FollowHyperlink would be one way of opening the files.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Hank153 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    19
    Quote Originally Posted by pbaldy View Post
    If you really have 2003 you can't click on a button anyway. 2007 introduced Report view, which is interactive. FollowHyperlink would be one way of opening the files.
    I recently installed 2007.

    I see FollowHyperlink - my problem is the code to refer to the file which is stored on my computer in another folder. As I said, each record would have a different file name, shown in FamilyFile1 field of the table and query.
    Thanks

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,289
    I am confused. The file is embedded in an OLEObject field or it is external in a folder? 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.

  5. #5
    Hank153 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    19
    It is in an external folder. A link is placed in the table/query field.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,289
    The folder path is not in a Hyperlink type field, just a plain text field?

    Then does Allen Browne code help?

    Here is more from Allen about hyperlinks http://www.allenbrowne.com/casu-09.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.

  7. #7
    Hank153 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    19
    I think I mis spoke.

    The field on the table data type is OLE object. The report is pulled from the query based on that table. My intent was to link the file to the table. If that can't be done with an OLE field, I guess I have it imbedded. Most of the files are small so I don't think it will make the database too large.

    Do you recommend changing it to a text field with the folder path?

    At any rate the problem is still installing a command button with code to open the file.

    Thanks

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,289
    Another recent thread on same topic https://www.accessforums.net/program...doc-38900.html

    Apparently Visual Studio allows editing embedded objects. http://msdn.microsoft.com/en-us/libr...(v=vs.80).aspx
    I don't know if code is transferrable to Access VBA.

    Here is another link about Access and embedded Word docs http://support.microsoft.com/kb/132240
    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
    Hank153 is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Dec 2012
    Posts
    19
    Thanks for your reply June7. I have read the links you gave but still dont understand what code to use. Sorry, I'm a little slow on this.

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    50,289
    I think I have had success embedding objects in OLE field but that would have been with 2007. I just tried with 2010 to embed a doc file in an OLEObject field and got an error message "The operation on the OLE object failed. The OLE server may not be registered. To register the OLE serve reinstall it." I have no idea what this error means nor how to resolve it.

    Isn't a file saved in OLEObject field supposed to automatically open in its native program when you double click on the field or OLEObject control bound to that field? If so, code shouldn't even be needed. I think the example in link is code for error handling. It goes behind DblClick event of OLEObject control instead of a command button. That's what I was going to try until I hit the above wall.

    I've never had fun with OLEObject field and controls.
    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.

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

Similar Threads

  1. Print report command button
    By Stika in forum Reports
    Replies: 5
    Last Post: 12-21-2012, 05:56 PM
  2. Command button to open Report
    By swagger18 in forum Programming
    Replies: 0
    Last Post: 11-17-2011, 02:56 AM
  3. Combo box & Command button to report
    By Solstice in forum Reports
    Replies: 4
    Last Post: 09-10-2011, 10:12 PM
  4. Replies: 1
    Last Post: 07-27-2010, 02:27 PM
  5. Form/report command button code
    By max3 in forum Forms
    Replies: 1
    Last Post: 08-26-2009, 02:18 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