How do Programmatically insert an ole object into an access database

I am working on a VBA program in MS outlook in which I am using ADO to update ms access database. It works fine for my text fields, but I am not sure how to update an Embedded Object field. Anyone know how I can do this

For example I have a database called C:/Test.mdb with table "My_Table" containing a field called "Email_Message" with data type OLE Object:

Function LogEmails()
Dim msg As MailItem
Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim strSQL As String
Dim FilePath As String

Set msg = ActiveExplorer.Selection.Item(1)

FilePath = "C:\Test.mdb"
Set cn = New ADODB.Connection
With cn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "data source=" & FilePath
.Open
End With
Set rs = New ADODB.Recordset
strSQL = "UPDATE [My_Table] SET [Email_Message] = " & msg & " WHERE [Item_ID] = 2"
rs.Open strSQL, cn
Set rs = Nothing

End Function

Thanks,

Dudeman



Answer this question

How do Programmatically insert an ole object into an access database