Display multiple attachments in microsoft access 2010 forms and reports

后端 未结 2 878
悲&欢浪女
悲&欢浪女 2021-01-06 03:40

I was initially very pleased to discover the attachment field in Access 2010. It\'s a feature that aesthetically irks my inner database purist but my inner lazy sod is in ch

相关标签:
2条回答
  • 2021-01-06 04:09

    I searched this for a similar problem. I have multiple attachments per field. I intend to use the field to store a .jpg and a .pdf for two image controls which I created by dragging the field from the properties to the form. I have named them ctlImage and ctlFeatures. I am using this form as a non modal popup from a more info button on the product catalog form. So far I am able to search records in the product catalog and use the selected listbox search result to open the form with a where clause to set the details form to the current record. When I try to manipulate the ctlImage looking for image type the only property which shows in intellisense is ctlImage.value. I was hoping to assign ctlImage to jpg and ctlFeatures to pdf Here is the frmProducts btnMoreInfo_Click code and the frmCatalogDetails code in case one is messing up the other.

    Private Sub btnMoreInfo_Click()
        Dim db As DAO.Database
        Dim rs As DAO.Recordset
        Dim str As String
        Dim row As Long
        Set db = CurrentDb
        Set rs = db.OpenRecordset("tblProducts", dbOpenSnapshot)
    
            If Me.lstSearchResults.ItemsSelected.Count > 0 Then
    
                ' Debug.Print Me.lstSearchResults.Column(0)
                row = Me.lstSearchResults.Column(0)
                rs.MoveFirst
                rs.FindFirst "ProductID=" & row
                Debug.Print rs("Description")
                DoCmd.OpenForm "frmCatalogDetails", acNormal, , "ProductID=" & Me.lstSearchResults.Column(0, Me.lstSearchResults.ItemsSelected), acFormReadOnly, acWindowNormal
    
            Else
                MsgBox "You must select a product"
                Exit Sub
            End If
    End Sub
    

    and Catalog details

    Option Compare Database
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim fld As DAO.Field
    
    Private Sub Form_Load()
    
        Set db = CurrentDb
    
        'Set rs = db.OpenRecordset("tblProducts", dbOpenSnapshot)
    
    
        'Set fld = rs("image")
    
        Debug.Print rs("ProductID")
        Debug.Print rs("Description")
        'me.ctlImage.ControlSource =
    
        'Me.ctlImage.CurrentAttachment = fld.Value    
    End Sub
    

    The rs statements are commented out because I am having trouble with this form recognizing the rs from the parent form. I am getting a with block variable not set, but if I do rs.openRecordSet then the recordset goes back to the first row. Aside from your answer above, I have seen very little about manipulating the attachment object and the help has been difficult as it doesn't even cover accessing inside the attachment field. I am at a point where I will do more asking than answering on this topic, and I very much appreciate the time many of you take to craft an answer. Rollin Motto: Ask for help when needed, give help when asked, and remember where you came from.

    0 讨论(0)
  • 2021-01-06 04:20

    Let us say I have a table with an attachment:

    attachment table

    Let us say that I have three images in one of those attachment fields that I wish to display. I can create a query:

    attachment query

    After which I can create a continuous form:

    attachment form

    0 讨论(0)
提交回复
热议问题