Image on Report?

C

Chris Cairns

I have images (qty 3) stored in a SQLdatabase which are used as logos on
various reports. Depending on the options the user selects different
logos may print on the report. My front end is an Access 2003 Project .adp.

My problem. The data for the report comes from a stored procedure. There
are many detail lines and I really do not want to include that image with
each row in the query so I would like to be able to access it separately
since it is only needed once. When I attempt to do this I end up with
errors or nothing displayed.

My question..... Ho can I manually access an image in the sql database and
display it on a report?

I tried something like...... The control source for the object frame
would be =GetLogo(value1,value2). I get a bunch of errors. Now this
seems to work fine if I just need text returned, but am having trouble with
the image.

Function GetLogo(strOfficeLocation As String, strClientID As String) As
ADODB.Stream

Dim cmd1 As ADODB.Command, rs As ADODB.Recordset

GetLogo.Type = adTypeBinary
GetLogo.Open

Set cmd1 = New ADODB.Command
cmd1.ActiveConnection = MakeConnectionString
cmd1.CommandText = "dbo.GetLogo"
cmd1.CommandType = adCmdStoredProc
cmd1.CommandTimeout = lngTimeOut
cmd1.Parameters.Refresh
cmd1.Parameters(1).Value = strOfficeLocation
cmd1.Parameters(2).Value = strClientID
Set rs = cmd1.Execute()
'Collect the data
GetLogo.Write rs.Fields("Logo").Value
Set rs = Nothing


End Function
 
S

Stephen Lebans

You need to save the data out to a temp disk file and then set the
Picture property of the Image control to point to the temp file.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top