Accessing Field2 in Access 2007

I'm trying to write a simple little procedure to send an attachment stored in an Access 2007 database. For some reason I can't get the simple part to work.

I am getting the error "User defined type not defined" on the following line:

Dim attachmentField As DAO.Field2

      

Now, up to this point, I have not yet accessed any DAO objects, but my guess was I only needed to add the appropriate link. Thing is, I seem to have a misconception about what this link is. I tried "Microsoft DAO 3.6 Object Library" which made sense, but I still get the same error message. Then I tried 3.5 of them, then JET and then a few more, which made much less sense.

Here's a complete list, in case I missed anything else that is a real basic one. I know it needs a huge cleanup, but I would like it to work first.

Private Sub Command4_Click()
  Dim appOutLook As Outlook.Application
  Dim MailOutLook As Outlook.MailItem
  Set appOutLook = CreateObject("Outlook.Application")
  Set MailOutLook = appOutLook.CreateItem(olMailItem)

  With MailOutLook
    .To = Description.Value
    .Subject = "Confirmation of " & ID.Value

    'Error on the next line
    Dim attachmentField As DAO.Field2
    attachmentField = Recordset("Att")
    attachmentField.SaveToFile "C:\Temp\" & Att.FileName
    Attachments.Add "C:\Temp\" & Att.FileName, olByValue, 1, "Document"

    '.DeleteAfterSubmit = True
    .Send
  End With
End Sub

      

Any ideas?

+1


source to share


2 answers


You need a link to DAO Version 12 which supports the new FIELD2 object



Try adding this link - "Microsoft Office 12.0 Access Database Engine"

+4


source


Change the line to

 Dim attachmentField As DAO.Field

      



Also, where does the Recordset come from? Where is it populated with entries?

-2


source







All Articles