UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Adding an image to table....    
 
   
Diversion
post Mar 3 2004, 04:11 PM
Post #1

New Member
Posts: 9



This might be one of the more redundant questions found on this forum, but I honestly searched through all day at work and cannot find a clear answer on how to do this. I'm just trying to add a snapshot to each record I have in my table. I changed the snapshot field to OLE OBJECT. I drag and drop a JPG or PNG file and it goes in as a "Package". A bitmap goes in as "Bitmap Image" and shows up fine, however, Access doesn't recognize a JPG/PNG/etc. as a image at all. I have the latest SR-2 update on my Office 97 installed. Please don't tell me you can only embed BMP files into a table.

Jay

Edited by: Diversion on 03.03.04.
Go to the top of the page
 
+
ScottGem
post Mar 3 2004, 04:19 PM
Post #2

UtterAccess VIP / UA Clown
Posts: 25,071
From: LI, NY



The general method is NOT to store such items in the table. This results in bloated tables. What you do is store the path to image file and then use that path to display the image in an unbound control. I'm sure you can find picture catalogs that illustrate this here or other Access sources.

I'll give you a specific example that I did. I developed a catalog of the artwork in our offices. Each piece of art was assigned a number and a picture was taken and stored with the same number. The pictures were all stored in an Images subfolder of the folder where the app was stored.

On my form I put an unbound Image control. In the On Current event of the form I put code like the following:

Me!imgPic.Picture = strCurrDir & Me!txtArtID & ".jpg"

In my case strCurrDir was equal to H:\Artwork\Images\. You can set strCurrDir in a variety of ways.

I also used an IF to test whether the file existed and load a default image if it didn't to avoid errors.


Go to the top of the page
 
+
ChrisLeClark
post Mar 4 2004, 06:00 PM
Post #3

UtterAccess VIP
Posts: 1,668
From: Chichester, Sussex, UK



Hi There
2 options that work fo rme.
If you have microsoft photo editor from Office 97 CD installed and this is default picture files viewer for your jpg's etc. then use this for OLE in table.

Or

Do Insert Object then choose Microsoft Clip Gallery if you have it as an option.
Choose picture tab in the gallery then import your pics.
Once imported select picture then insert.

Hope that works for you.
Chris
Go to the top of the page
 
+
Shane
post Mar 5 2004, 10:03 AM
Post #4

UtterAccess Veteran
Posts: 403
From: Northern Ireland



Scott

You say that you used an IF statement to test if the file exists. How did you do this?
I want to allow users to use any file typs such as jpg, bmp, gif etc. but I'm not sure how to do this

Thanks
Shane
Go to the top of the page
 
+
ScottGem
post Mar 5 2004, 10:46 AM
Post #5

UtterAccess VIP / UA Clown
Posts: 25,071
From: LI, NY



This is the code I use:

Private Sub Form_Current()
Dim strFile As String

strFile = CurrDBDir() & "\images\" & Me!txtArtworkID & ".jpg"
If Dir(strFile) = "" Then
Me!imgPic.Picture = CurrDBDir() & "\images\notavail.jpg"
Else
Me!imgPic.Picture = strFile
End If

End Sub

CurrDBDir is a custom function as follows:
Public Function CurrDBDir()
Dim strDBPath As String
Dim strDBFile As String

strDBPath = CurrentDb.Name
strDBFile = Dir(strDBPath)
CurrDBDir = Left(strDBPath, Len(strDBPath) - Len(strDBFile))
End Function

So the result is to build the path and filename as strPath then use the DIR function to determine if it exists.

If you want to use other then JPGs, then store the whole filename in your table record and drop the & ".jpg" from my example.
Go to the top of the page
 
+
Shane
post Mar 5 2004, 11:37 AM
Post #6

UtterAccess Veteran
Posts: 403
From: Northern Ireland



So that's how you do it.

Thanks Scott

Shane
Go to the top of the page
 
+
Diversion
post Mar 8 2004, 10:48 AM
Post #7

New Member
Posts: 9



ChrisLeClark, the 2nd option seems to work for me, although degrades the quality of the image a bit, any ideas?

Jay
Go to the top of the page
 
+
ChrisLeClark
post Mar 9 2004, 07:44 AM
Post #8

UtterAccess VIP
Posts: 1,668
From: Chichester, Sussex, UK



Hi Jay,
Picture quality should be as good as your saved picture.
In your bound object frame properties - look for the size mode property on the all tab and ensure it is set to zoom and your picture will display fully within the boundary of your bound object frame. If all of your pics are of similar height / width ratio then you can set the bound object frame height / width ratio siimilar.

I have no probs with picture quality providing the source image is sound.

Another thing I do is store all my pics in a seperate database. I have a table that contains the ID field and a picture field. This table stores the pics embedded, not linked. My main database contains a link to the table in this seperate pics database. In my main database I display the pictures in a subform which is using the linked table as the recordsource. Yes, my picture table becomes very bloated but it doesn't impair the performance of the main database because that is only updating each picture as it is accessed. I keep the pics database in the same folder as the main database or in a sub folder of the main database folder.

I thinks some of the earlier answers given provided better ways of storing pictures but given my Access limitations this was a good way for me and it works with minimal delay.

Hope this helps.

Chris
Go to the top of the page
 
+
jabetcha
post Nov 13 2004, 06:04 PM
Post #9

New Member
Posts: 1



Hello,

I was wondering if anyone has suggestions on how to make this work with large reports. I have a database with artwork information for over 7000 pieces of art. All the images are stored in a folder with the same image number as JPG's. However, when I go to print a report with all the images in it, it dies after about 10 pages (4 images per page) because it runs out of memory. I have attempted to shut all other applications down, but it only helps marginally. If the images are smaller in size, it may process a few more pages before crashing.

I'm already doing the recommendations from earlier in this post. I'd like to know if there's a way to spool the report directly to the printer after each page's layout is completed or break up the report in an easy way.

Thanks.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 22nd May 2013 - 06:48 AM