Form Image ( [catalog]+".jpg" )

Piney

n00b
Local time
Tomorrow, 03:44
Joined
Feb 21, 2008
Messages
4
Being a newbie at access and I thought what better way to learn more than making my own database.

I am building a database to store information on my vinyl.
I want to have an image for each record.
My primary key is the catalog ref which is stored in the [Catalog] colum.
I will store these images named "catalog".jpg in a folder.
Can I show the images on my form with something like [catalog]+".jpg"?
If so how would i go about this?

Ps. I have been searching for ages and cant find thread that answers my question.
 

Attachments

Depending in your version of Access, it seems to me the Employee section of the NorthWind sample that ships with Access shows how to do this. There are also some examples that Larry Linson put up on his site.
 
Being a novice I have no idea how to incorperate that Larry Linson example into my database.
and i dont want to have to set what image to use, I want it to automatically look for the file with the same name as the catalog colum for that entry.

The NorthWind example uses ole objects

PS. I'm using Access 2003 SP1
 
Last edited:
Your first post indicated you started this project to learn Access. Why not just consider incorporating Larry's ideas part of your learning process?
 
Ask specific questions about Larry's code and they can be answered.
 
If you are going to use external files then the pictures are being displayed in the Open and Current events of the frmImageFileDetail form.
 
As Allan has so kindly pointed out, you will need to place code into the OnCurrent event of the Form. I have attached you sample DB showing this and the code window below.

For this to work you will need to place ALL your Images (jpegs) into a Folder named "Images" within the same Folder the Database is in. For example:
If your Database is in E:\MyDBs\ then you will need to make a folder E:\MyDBs\Images\ and place all your Image files there.

It's either that or add a Field in Table that can hold the Path to the Image related to each Table Record. If you do this then the Code below will need to be changed. This I think may be the better route to take because this way you can organize your Images better (not all in one pile).

Code:
Private Sub Form_Current()
   Dim ImageStrg As String

   On Error Resume Next

   If IsNull(Me.Catalog) = False Then
      ImageStrg = Application.CurrentProject.Path & "\Images\" & Me.Catalog & ".jpg"
   Else
      ImageStrg = ""
   End If

   Me.Img0.Picture = ImageStrg

   If Err <> 0 Then Err.Clear
End Sub
.
 

Attachments

Users who are viewing this thread

Back
Top Bottom