Results 1 to 3 of 3
  1. #1
    MatthewFF is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    USA
    Posts
    2

    Access 2007 Code Guru please: Unbound Attachment

    Hello:

    Since Attachment data type and Attachment control are new to Access 2007, limmited programatic/sample-code availbale on the web.
    So looking for assistance with Attachemnt Data Type with Unbound Attachment Control in Access 2007.

    On a form, an Attachment control has been added, which is unbound (note, the control must remain unbound). Programatically (VBA), how would an attachment (in this case a pdf) stored within a table, be "populated" within the form?

    Expanding on the question, what aspects of the Attachment data type (archived within a table which have properties of .FileData , .FileType, and .FileName etc) would be used in assignment to the Attachment control within form? Which of the control's properties need setting?

    With "Me.ControlAttachment" being the form's attachment control, here is some simple code for trying to describe the issue . . .

    Dim RecSet As DAO.Recordset
    Dim rstAttachment As DAO.Recordset
    Set RecSet = CurrentDb.OpenRecordset("SELECT PDFid, myAttachment FROM tPDF WHERE PDFid =1")
    Set rstAttachment = RecSet!myAttachment.Value
    ' Help Start


    Me.ControlAttachment.???? = rstAttachment!????
    ' Help End
    rstAttachment.Close
    RecSet.Close

    I have exhaustively searched the web on a few occasions, with no success. Ironically, some similar posts on this issue have occurred in various forums, which have all gone un-answered.

  2. #2
    llkhoutx is offline Competent Performer
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Location
    Houston, Texas USA
    Posts
    373
    Dim RecSet As DAO.Recordset
    Dim rstAttachment As DAO.Recordset
    Code:
    Set RecSet CurrentDb.OpenRecordset("SELECT myAttachment FROM tPDF WHERE PDFid =" 1)
    me.ControlAttachment RecSet.Fields(0
    rstAttachment.Close
    RecSet.Close

  3. #3
    MatthewFF is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    USA
    Posts
    2
    * Thanks for attempted assistance, however, the suggestion did not work. Details as follows:
    - Confirmed within local variables via breakpoint, that RecSet was valid/correct.
    - The assigmnet (me.ControlAttachment = RecSet.Fields(0)) causes a Run time error of 438, Object does not support this property or method.

    * Of note: while the attachment data type can hold one or more attahments in the table, for simplicity, I only have one attachment per record within the table.

    * Next step/suggestion please?????

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

Similar Threads

  1. Attachment Field problems
    By freds in forum Database Design
    Replies: 1
    Last Post: 12-15-2009, 06:37 AM
  2. Access 2003 code vs Access 2007 Code
    By ralphjramirez in forum Access
    Replies: 5
    Last Post: 11-23-2009, 12:33 PM
  3. Replies: 0
    Last Post: 11-17-2009, 02:35 PM
  4. Access 2000 and 2007 VB code
    By gnuman in forum Access
    Replies: 0
    Last Post: 08-26-2009, 05:55 AM
  5. email attachment from Access
    By Gandalf in forum Queries
    Replies: 0
    Last Post: 01-22-2009, 10:03 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