Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linked Pictures in Continuous Forms

Status
Not open for further replies.

BRANDON99

Technical User
Aug 29, 2003
52
FR
Hi
I have searched this forum without luck. I would like to create a continuous form that displays a linked picture. I am sure I have seen this done but I am unable to find a way to achieve it. Can anyone help please. I am using Access 2003 but could install Access 2007 if this helps

Thanks for your help
 
If the picture is not in the database this can not be done.
On a continuous form there is only one instance of the control. So if you change the property of the control all other renderings would change.

If the control is bound then you can display the correct record in the renderings of the control. Access does a far far better job of storing images without bloating. The easiest solution is to switch to 2007 and store the images in the database as ole objects.

If you do not want to store the image in the db, another solution for continous images is to use a list view. Then as the form loads, load the images into the list view. Final solution is to use a report not a form, because you can use the print event of the report to load a different image per record.
 
Should read: Access 2007 does a far far better job of storing images without bloating.
 
Thanks MajP

I installed Access 2007, added the pictures to the data base. Iys doesn't appear to be much smaller than if I used Access 2003, down from 84000 to 74000. Am I doing it wrong?
 
General Information about the Attachment DataType:

As discussed in some of the earlier tutorials Access 2007 implements a new, very useful DataType. The Attachment DataType is a multi-valued field that replaces the OLE Object DataType in the new ACCDB file format. Keep in mind that such complex data is only available in the ACCDB file format and not in the prior MDB formats.

The Attachment DataType works as a multi-valued field which you might think breaks normalization rules. Microsoft® ensures us that the data is stored in a relational manner at the most basic level within Access itself.

The main purpose of the new DataType is to eliminate the bloating issues the OLE Object DataType exposed when embedding external files within your application. In all versions prior to Access 2007 it was almost always suggested to link to external files with a Text DataType. Using a Text DataType field which holds the full string directory path and file name of the external file at the Table level would enable you to work around the bloating issue and still utilize external files within your application. However, one of the drawbacks of this set up is to always depend on an external folder holding your files which itself always needs to be moved along side the application.

The Attachment DataType can eliminate this set up by allowing you to directly embed files within your application. If the files are not already compressed Access will store them in a compressed manner for you to keep the ACCDB file size as small as possible.

Though the 2GB file size limit still might stir you in a direction of a set up mentioned earlier with storing the files externally and linking to them. Another alternative would be to create an ACCDB file solely for holding your files in a table utilizing the Attachment DataType and then linking to that ACCDB file from your application file. One scenario where either of those methods might be more suitable could be the plan to utilize an extremely large amount of files within your application or the file size of individual files being somewhat large.

 
The problem is Access doesn't create separate controls for each record - or it would hang trying to display really big table. There is no straight workaround for this. The only way to do this is to generate small previews for each picture and store them in DB as OLE bitmaps. Then you display em with "Bound Object Frame" Its hard to code such a trick by your own - but you can try AccessImagine ( ) ActiveX control, it does a trick easily. Beside that it allows to put images to database in one click - load, paste, scan or drop.
 
This might help, I use it on a dashboard, every time it is opened a new picture is shown. Where YourTableName is a table of picture names not a table of pictures


Dim db As DAO.Database, rst As DAO.Recordset, Pth As String

Set db = CurrentDb
Set rst = db.OpenRecordset("YourTableName", dbOpenDynaset)
Randomize 'set seed via system timer

rst.MoveLast
rst.AbsolutePosition = Int(rst.RecordCount * Rnd)
Me!Image1.Picture = "C:\Users\Documents\Pictures\pictures" & rst![fieldname]

Set rst = Nothing
Set db = Nothing
 
This is a post from ZiggyS1 I use, was used in they above, which Acemane combined with DAO

Just add an image control, and in the OnCurrent" event of the FORM place this...


CODE

Private Sub Form_Current()
Dim path As String

If Me.Filename <> "" Then

path = "C:\Documents and Settings\User\My Documents\Images\"

Me.Image1.Picture = path & Me.Filename

End If

End Sub

*** the Me.Filename is the name of a text box that holds the filename. As you change records if you have the field filled in with a valid filename the image will appear.

 
timhans, the bad news is your method doesn't work for Access continuous forms.

But in Access 2007 you can bind a regular "Image" component to field with path and image filename to display it. Or you can even provide a query to generate it (i.e. add some path to filename).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top