Bound object frames

Pat Hartman

Super Moderator
Staff member
Local time
Today, 12:54
Joined
Feb 19, 2002
Messages
47,102
A2010 full and runtime/various versions of Windows from XP to Win7.

Does anyone know the trick to getting the BOUND object frame to show a .jpg? I can get it to show a spreadsheet but for .jpg's, it just shows an icon. I thought it had something to do with which program is registered to open .jpg files but I've tried every one I could think of and not been able to get this to work.

I can't use the attachment data type since that isn't supported by SQL so it has to be the OLE Object.

I know storing graphics bloats the database but there will only be a few dozen of them and I don't want them as separate external files because that causes distribution and security issues (these are signature files).

I posted this under forms but I'm sure I'm going to have the same problem with reports when I get to that point.
 
The best way is to assign the image file to an Image control.

Code:
Function GetPicture()
    With CodeContextObject
        If GetPictureExist = True Then
            .[ImageControl].Visible = True
            .[ImageControl].Picture = GetPicturePath
        Else
            .[ImageControl].Visible = False
        End If
    End With
End Function

OR

Store the entire image file name of the form and then in the Control source put =[ImageFile] this is Access 2007 and as I developed in Access 1997 I haven't used this method as it was unavailable.

Simon
 
I am trying to use a BOUND control. Also, the code you posted doesn't compile so you are not using VBA objects.
 
Pat.

If they can be converted to monochrome bitmaps they can be inserted directly using ‘Create from file’.

Chris.
 
I have added the signatures to the table. The problem is that they display as icons rather than graphics. If I replace the signature jpg with a random xls file, the spreadsheet shows just the way it should.
 
Pat.

Does the attachment work for you?

Chris.
 

Attachments

Thanks Chris. It works perfectly. I now need to figure out what is different about mine. What is the file type of your files and how did you load them? Mine are .jpg and I was using the shortcut menu (right click) to add them.
 
Hi Pat.

They are monochrome bitmaps (quite small) and were inserted using ‘Create from file’.

Chris.
 
Thanks Chris. The problem seems to be with jpg's. I loaded my jpg into your app and it only displayed the icon so I converted the files to .bmp and that solved the problem. The bmp's are 10 times the size of the jpg's but I only have about two dozen to add so I'm hoping the database doesn't bloat too much.
 
Pat,

My fault: First I establish where the images are stored

Code:
Function GetPictureDir() As String
    GetPictureDir = Forms![Menu]![Image Directory]
End Function

Then associate the image location with the imagefile from a query
Code:
Function GetPicturePath()
    With CodeContextObject
        GetPicturePath = GetPictureDir & .[Image File]
    End With
End Function

Then establish if an image exists:
Code:
Function GetPictureExist()
        If Dir(GetPicturePath) <> Empty Then
            GetPictureExist = -1
        Else
            GetPictureExist = 0
        End If
End Function

Then render the image Form > OnCurrent

Code:
Function GetPicture()
    With CodeContextObject
        If GetPictureExist = True Then
            .[ImageControl].Visible = True
            .[ImageControl].Picture = GetPicturePath
        Else
            .[ImageControl].Visible = False
        End If
    End With
End Function

Simon
 
Pat.

If you don’t need colour information in the signatures then convert them to monochrome bitmaps and they will be about the same size as a jpeg.

The jpegs I converted from were 4k and the monochrome bitmaps I converted to were 5k.

Chris.
 
@Chris, your samples were not good enough to use as signatures but I'll see if I have some software with the option to save as b&w and if that degrades the quality too much. I knew bmp's were huge, that's why I started with jpg's. I wish I knew why the jpg's won't render but I've wasted enough time on this problem so I'm moving on. There's not enough signature files to cause a problem so I can live with the bmp's even though they are huge in comparison to the jpg's.

Anyone who can tell me "why" bmp works and jpg doesn't gets a beer.

@Simon, thanks but I am using a BOUND control. That means that the actual file is stored in a field in the table. You are trying to solve a different problem.
 

Users who are viewing this thread

Back
Top Bottom