G
GinKirk
Hi: I need help with loading pdf documents from the filesystem into a
SQL Server table for display in forms & reports in a linked Access
front-end. I think the pdf files are getting loaded into the database,
but aren't displaying correctly in Access.
I run code below to update the abstract field with a pdf file. Then
when viewing the field in a OLE control on a form bound to a linked
table, nothing appears. When double-click to open in pdf, the
following error appears: A problem occurred while MS Access was
communicating with the OLE server or ActiveX Control. Close the OLE
Server and restart it outside of Access. Then try the original
operation again in Access"
I can manually load this pdf by selecting to Insert Object...from the
menu bar and see the document in the Access form.
In SQL table, the "Abstract" field datatype is Image.
Here is the sample code to upload the abstract from the C:\myfile.pdf:
=============================================
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim stm As New ADODB.Stream
With cn
.ConnectionString = strconnect
.Open
End With
rs.Open "select * from tblProp_Abstracts where ProposalID=301", cn,
adOpenKeyset, adLockOptimistic
stm .Type = adTypeBinary
stm.Open
stm.LoadFromFile "c:\myfile.pdf"
rs!Abstract = stm.Read
rs.Update
cn.Close
====================================================
When I debug.print Rs!Abstract a lot of characters appear, so I'm
thinking the file is loaded. Thanks.
SQL Server table for display in forms & reports in a linked Access
front-end. I think the pdf files are getting loaded into the database,
but aren't displaying correctly in Access.
I run code below to update the abstract field with a pdf file. Then
when viewing the field in a OLE control on a form bound to a linked
table, nothing appears. When double-click to open in pdf, the
following error appears: A problem occurred while MS Access was
communicating with the OLE server or ActiveX Control. Close the OLE
Server and restart it outside of Access. Then try the original
operation again in Access"
I can manually load this pdf by selecting to Insert Object...from the
menu bar and see the document in the Access form.
In SQL table, the "Abstract" field datatype is Image.
Here is the sample code to upload the abstract from the C:\myfile.pdf:
=============================================
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim stm As New ADODB.Stream
With cn
.ConnectionString = strconnect
.Open
End With
rs.Open "select * from tblProp_Abstracts where ProposalID=301", cn,
adOpenKeyset, adLockOptimistic
stm .Type = adTypeBinary
stm.Open
stm.LoadFromFile "c:\myfile.pdf"
rs!Abstract = stm.Read
rs.Update
cn.Close
====================================================
When I debug.print Rs!Abstract a lot of characters appear, so I'm
thinking the file is loaded. Thanks.