Adding multiple photos to an item

aian

Registered User.
Local time
Today, 14:16
Joined
Jan 28, 2005
Messages
70
Hello to all!

I am building a new database and I'd like a bit of help

The database stores various items for which there will be 1 or 2 or 3 photos of each, along with other fields such as description, date of acquisition etc.

How exactly do I create the table so that I can store 3 pictures on each item? I've read all the threads regarding picture management but I didn't find any clues when it comes to more than one photo per item.

Furthermore, I'd like some guidance on how to create a form to enter the data (an image path I suppose) so that when the user adds a new item, he will be able to add a photo by clicking a button that opens Windows explorer to help him find the path of the stored picture file.

I think the naming system I am following would help somehow. All the items will have a code such as ABC.1234 so I think the photos should be stored as

ABC.1234.1.JPG
ABC.1234.2.JPG
ABC.1234.3.JPG

so as to make it easier for the user to add the photo of each item in the appropriate folder. The photos will be stored in the same folder with the database file, in a subfolder named \photos.

Any ideas?


Thank you
 
Check the Northwinds sample data base that comes with Access.

Go to Help and then sample data bases

The form Employees is the place to go.

They use BMP images and that is what I use. You can save JPG
as BMP by opening the file in Paint and then doing saveas. Paint will also let you adjust the size of the image.
 
Thank you Mike.

The problem is how do I add more than one picture per item, so that this 2nd or 3rd picture is viewable both in the form an the possible reports that will be created.
 
Oh, I got it now, sorry...


Thanks again Mike!
 
Well, I'm afraid I didn't manage to sort it out...

Northwind does have a sample of what I'm looking for in the Employees form, but I can't understand how to create a button in a form to add a photo.

It looks like I have to add some code behind the "ADD PHOTO" button that I'm unaware of. Also, how do I create a BLANK frame that will be the placeholder for the photo? Whenever I try to add a new photo, it asks me to select one from a folder in my computer...

Some help please?
 
I can't help you there. I use code to embed or link to an OLE field and that is mostly for Word and PDF files. I don't do it that way because it is better, in fact my understanding is that OLE is an inferior way to do things, but it does for what I do and I am set up for it.

Go behind the buttons and look at the code. For example, on the add/change button you will see getFileName. You will find that is calling a sub associated with the form. If you go into the code you can go to Edit and Find and do that for both forms and modules and will show you what some thing like getFileName is calling.

I have never used image frames so I would have to do what you will need to do and that is go to Google, unless some angel appears on this thread:D

With your photo/files you will probaly find you can store them, that is the full file name/path in an Access table and insert them from there. You can do this type of thing from a tabular form. You do like this

.SourceDoc = ("C:\Letters\" & Format([Forms]![FormOleLink]![LNameNoDoc]) + ".bmp")

That is a line from where I put something in an OLE field and as you can see it is using the path/file name as stored in Access.

You might find "you can cheat" and adapt the Northwinds to your situation:)
 
Thank you Mike once again!

Any angels in here pleeease?
 
You require a Parent table for the item, and a child table to hold the photos. The child table will hold the primary key of the item as a foreign key.
However standard practice is to store a link to the photo and not the photo itself as your db will bloat to the point where you may wait a minute or two for a photo to show.

I believe in later versions of Access images may be store in compressed format
 
Dennisk, can you please explain more in detail what you mean?
I'm certainly not going to store photos in the database (bloat-alert, as you noted), but I don't quite understand what you mean.
Thank you.
 
If you are not using Access 2007 with it proper handling of images, you don't want a button to ADD photo but reference the image. I use Dbpix (ActiveX) to do this which is a paid for application. I prescribe the image path and file dependent on the record and use:

Code:
Function GetImage()
Dim FullPath As String
    With CodeContextObject
        FullPath = GetImageDir & .[Image File]
        If Dir([FullPath]) <> Empty Then
            .[ActiveXCtl0].Visible = True
            .[ActiveXCtl0].ImageLoadFile (FullPath)
        Else
            .[ActiveXCtl0].Visible = False
            .[ActiveXCtl0].ImageClear
        End If
    End With
End Function

You would have to reinterate this each time for the number of image controls you have. The Access 2007 solution looks like this:

Code:
Function GetPicture()
Dim FullPath As String
    With CodeContextObject
        FullPath = GetImageDir & .[Image File]
        If Dir([FullPath]) <> Empty Then
            .[ImageControl].Visible = True
            .[ImageControl].Picture = FullPath
        Else
            .[ImageControl].Visible = False
        End If
    End With
End Function

In both cases the [Dir] determines whether or not an image file exists and load an image if found or make the control invisible if not available.

Simon
 
Upgrade to A2007 and use the attachment type.

Thank you. Are there major differences between Access2003 and Access2007 versions? I mean, do I need to learn everything from scratch?
 
The main problem is the Ribbon and drop-down menus. Basically, it is the same however there may be other areas that need attention but you can always post in the forum if you have any problems. I went from Access 1997 straight to Access 2007 with comparatively few problems.

Simon
 
Its such a good application here is the SetImage function, it updates the Image [Flag], aspect and size and stores this information on the database. The image I use go up to the web, so I want to know whether or not there is an image, the aspect for page rendering and if the images' file size is to large.

Code:
Function SetImage()
Dim FullPath As String
        
    With CodeContextObject
        FullPath = GetImageDir & .[Image File]
              
        If Dir([FullPath]) = Empty And .[Image] = -1 Then
            .[Image] = 0
        ElseIf Dir([FullPath]) <> Empty Then
            If .[Image] = 0 Then
               .[Image] = -1
            End If
            If .[Image Width] <> .[ActiveXCtl0].ImageWidth _
            Or .[Image Height] <> .[ActiveXCtl0].ImageHeight Then
                .[Image Width] = .[ActiveXCtl0].ImageWidth
                .[Image Height] = .[ActiveXCtl0].ImageHeight
                .[Image Size] = .[ActiveXCtl0].ImageBytes
            End If
        End If
    End With
End Function

I still use this in Access 2007.

I'm pleased it helped, many thanks again to ammara.com

Simon
 

Users who are viewing this thread

Back
Top Bottom