By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,660 Members | 1,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,660 IT Pros & Developers. It's quick & easy.

How to put logo in form?

P: n/a
Is it possible to store a company logo (a gif file) in a table (binary
field) and have the logo appear in a form? If I insert a picture object in
the form, the properties sheet of the Image control has a Picture field that
takes a file path. How do I reference the gif file stored in the table?

Thanks in advance.
Nov 13 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Just bind the form to the table and add a Bound Object Frame to the
form. You can then set the Control Source property to the field
containing the image.

Nov 13 '05 #2

P: n/a
Load the Logo into an Image control on a Form. Now copy the Image
control's PictureData property in your Long Binary(OLE) field. You are
not embedding the Image as an OLE object into an OLE object field. This
is simply a copy of the property stored as plain binary data.

At runtime you can reverse the process and copy the contents of your
field directly to the Image control's PictureData property.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <de**@hotmail.com> wrote in message
news:XO*******************@newssvr13.news.prodigy. com...
Is it possible to store a company logo (a gif file) in a table (binary
field) and have the logo appear in a form? If I insert a picture object in the form, the properties sheet of the Image control has a Picture field that takes a file path. How do I reference the gif file stored in the table?
Thanks in advance.


Nov 13 '05 #3

P: n/a
> Load the Logo into an Image control on a Form. Now copy the Image
control's PictureData property in your Long Binary(OLE) field. You are
not embedding the Image as an OLE object into an OLE object field. This
is simply a copy of the property stored as plain binary data.

At runtime you can reverse the process and copy the contents of your
field directly to the Image control's PictureData property.


Thanks for the reply.

But I don't see any PictureData property in the Image controls' property
sheet. I was able to follow rsinclair's suggestion of adding a bound object
frame to the form, and then setting the Control source to the OLE Object
field in the table - but how do I get the logo into the Long Binary table
field?

This must be a very simple procedure - thanks for your patience.
Nov 13 '05 #4

P: n/a
> Just bind the form to the table and add a Bound Object Frame to the
form. You can then set the Control Source property to the field
containing the image.


Sounds reasonable... I found some code on the net and modified it - is this
the right way to get the logo into the Long Binary table field?

Public Function GetBlob()
On Error GoTo HandleErr
Dim strSource As String
Dim strChunk As String
Dim intSourceFile As Integer
Dim lngFileLength As Long
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rst = db.OpenRecordset("tblSettings")
strSource = "C:\path\to\logo.gif"
intSourceFile = FreeFile
Open strSource For Binary Access Read As intSourceFile
lngFileLength = LOF(intSourceFile)
Debug.Print lngFileLength 'returns 5767
strChunk = lngFileLength
With rst
.MoveFirst
.Edit
!Logo.AppendChunk (strChunk)
.Update
End With
Exit_Here:
On Error Resume Next
Set db = Nothing
Set rst = Nothing
Exit Function
HandleErr:
Debug.Print Err.Number & " " & Err.Description
GoTo Exit_Here
End Function
Nov 13 '05 #5

P: n/a
In some versions of Access, the PictureData property is mistaken marked
as hidden in the Type Libary. Open the object Browser window, right
click anywhwere and select Show Hidden Members.
Anyhow, even if the PictureData prop does not show within Intellisense
you can still use it directly.

I posted sample code. Did you even try it?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <de**@hotmail.com> wrote in message
news:A1*******************@newssvr13.news.prodigy. com...
Load the Logo into an Image control on a Form. Now copy the Image
control's PictureData property in your Long Binary(OLE) field. You are not embedding the Image as an OLE object into an OLE object field. This is simply a copy of the property stored as plain binary data.

At runtime you can reverse the process and copy the contents of your
field directly to the Image control's PictureData property.
Thanks for the reply.

But I don't see any PictureData property in the Image controls'

property sheet. I was able to follow rsinclair's suggestion of adding a bound object frame to the form, and then setting the Control source to the OLE Object field in the table - but how do I get the logo into the Long Binary table field?

This must be a very simple procedure - thanks for your patience.


Nov 13 '05 #6

P: n/a
You can only use an OLE Frame control to view data that has been
inserted by an application that can function as an OLE Server for the
particular file type.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <de**@hotmail.com> wrote in message
news:qF*******************@newssvr13.news.prodigy. com...
Just bind the form to the table and add a Bound Object Frame to the
form. You can then set the Control Source property to the field
containing the image.
Sounds reasonable... I found some code on the net and modified it - is

this the right way to get the logo into the Long Binary table field?

Public Function GetBlob()
On Error GoTo HandleErr
Dim strSource As String
Dim strChunk As String
Dim intSourceFile As Integer
Dim lngFileLength As Long
Dim rst As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb
Set rst = db.OpenRecordset("tblSettings")
strSource = "C:\path\to\logo.gif"
intSourceFile = FreeFile
Open strSource For Binary Access Read As intSourceFile
lngFileLength = LOF(intSourceFile)
Debug.Print lngFileLength 'returns 5767
strChunk = lngFileLength
With rst
.MoveFirst
.Edit
!Logo.AppendChunk (strChunk)
.Update
End With
Exit_Here:
On Error Resume Next
Set db = Nothing
Set rst = Nothing
Exit Function
HandleErr:
Debug.Print Err.Number & " " & Err.Description
GoTo Exit_Here
End Function


Nov 13 '05 #7

P: n/a
> You can only use an OLE Frame control to view data that has been
inserted by an application that can function as an OLE Server for the
particular file type.


That must explain the error I receive when I double-click the empty box that
appears in the form - "server not available" or some such thing...
Nov 13 '05 #8

P: n/a
> In some versions of Access, the PictureData property is mistaken marked
as hidden in the Type Libary. Open the object Browser window, right
click anywhwere and select Show Hidden Members.
Done. I see PictureData in the Object Browser, but still not in the
property sheet of the control.
Anyhow, even if the PictureData prop does not show within Intellisense
you can still use it directly.
I do see the property in the Intellisense dropdown.
I posted sample code. Did you even try it?


Sample code? You posted sample code? In this thread?

Just for grins, I tried loading the logo into the table field using that
GetBlob function (see pervious reply to rsinclair), and then cleared the
path from the Picture property of the Image control. Then I added this code
to the form module:

Private Sub Image1_Click()
Me!Image1.PictureData = Me!Logo
End Sub

I get: Run-time error 2192: The bitmap you specified is not in a
device-independent (.dib) format.

Is this a result of the way I loaded the logo into the field with GetBlob,
or because the logo is a gif?

If you could repost your sample code, I'm sure that would help.

Thanks.
Nov 13 '05 #9

P: n/a
The GIF file is actually converted to an Enhanced Metafile by Access
when loaded into an Image control. I ran into this issue several years
ago but honestly have forgotten the workaround.
Convert your GIF to Bitmap format and you will be able to use the code
you posted. If this is not possible/practical then you will have to work
with temp disk files.

Copy the GIF intact to the long Binary field
At runtime copy the contents fo the long Binary field to a temp disk
file. Point the Picture prop of the Image control to this temp disk
file.
It was pseudo code I posted because it is too simple to bother writing
actual code.

To save the PictureData prop:
Me!YourOLEFieldName = Me.ImageControlNamePictureData

To Load:
Me.ImageControlNamePictureData = Me!YourOLEFieldName

You seem to want to use GetChunk which is not required. Just substitute
your Recordset object for "Me" when you do not want to have the
recordset bound to the form containing the Image control.

Good luck.
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.
"deko" <de**@hotmail.com> wrote in message
news:I0******************@newssvr21.news.prodigy.c om...
In some versions of Access, the PictureData property is mistaken marked as hidden in the Type Libary. Open the object Browser window, right
click anywhwere and select Show Hidden Members.
Done. I see PictureData in the Object Browser, but still not in the
property sheet of the control.
Anyhow, even if the PictureData prop does not show within Intellisense you can still use it directly.


I do see the property in the Intellisense dropdown.
I posted sample code. Did you even try it?


Sample code? You posted sample code? In this thread?

Just for grins, I tried loading the logo into the table field using

that GetBlob function (see pervious reply to rsinclair), and then cleared the path from the Picture property of the Image control. Then I added this code to the form module:

Private Sub Image1_Click()
Me!Image1.PictureData = Me!Logo
End Sub

I get: Run-time error 2192: The bitmap you specified is not in a
device-independent (.dib) format.

Is this a result of the way I loaded the logo into the field with GetBlob, or because the logo is a gif?

If you could repost your sample code, I'm sure that would help.

Thanks.


Nov 13 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.