How to display JPG images

Gkirkup

Registered User.
Local time
Today, 00:42
Joined
Mar 6, 2007
Messages
628
I have an application which uses many thousands of part numbers. I also have a folder with many thousands of photos of those parts, all in JPG format. How can I display those from my application? It need not be on a form, just stand-alone images would be fine. In the past I have used BMP images in Access, but it is not practical to convert all the images to BMP.

Robert
 
Create an image control and make the image linked, not embedded. Programmatically set the control's picture property to the location of the image in the form's current event.
 
Speakers: Thanks. I am just getting started with this. How do I create an image control?

Robert
 
Another way to do it is to simply store the path to the file as text in the database then open the file to that path in its associated program using code.

This has the advantage over the linked file technique allowing you to store just the filename or the unique parts of the path. Common path information is better stored in a constant which can be easily changed if the files are moved to another location.

You definitely would not want to embed the files in the database because it woud become too large. Access is limited to 2GB total size. You could change the BE to MS SQL Server Express wich will get you to 4GB in versions up to 2008 or 10GB in 2008 R2.
 
Last edited:
The JPG Add-on allows the use of compressed bitmap graphics in the form of JPG files. We provide you with the ability to keep your image files small and compact instead of using the default BMP image file support.
 
What do you mean by 'we' Rodrick? Is there a link coming in 9 posts?
 
From Access 2007, native file formats like jpg and gif are fully supported. This is a major improvment and can be used bound or unbound, on forms and reports. Even using 16,000 images there is noi footprint on the database with the blobs. OLE is difinitely a NO NO - bloatware.

The trick is to name the images to correspond with a unique record ID. Handling a large quantity of images sub-directories can be used to catagorise these images. Image file sizes are still important and whiilst this is a generalisation, images should be under 100KB, so low resolution images are imperative. Image dimensions affect size, I stick to 500 pixels max as a 1000 x 1000 image is four times the size of an image of 500 x 500 pixels.

Simon
 
Another way to do it is to simply store the path to the file as text in the database then open the file to that path in its associated program using code.

This has the advantage over the linked file technique allowing you to store just the filename or the unique parts of the path. Common path information is better stored in a constant which can be easily changed if the files are moved to another location.

You definitely would not want to embed the files in the database because it woud become too large. Access is limited to 2GB total size. You could change the BE to MS SQL Server Express wich will get you to 4GB in versions up to 2008 or 10GB in 2008 R2.

Could you shed some light on how to accomplish this coding? I am working on this same idea except with pdf's and am having issues.
 
It is just a matter of storing the filename and path as strings then using the Shell function to open the file when you need to view it.

What kind of problems are you encountering?
 
Well, following a recommendation from another thread, here is my code
Code:
Private Sub View_Drawing_Click()
Dim FileName As String
    FileName = Me.DrawingName.Value
    Call OpenDocument(("S:\Engineering\AutoCad\bases" & FileName & ".pdf"))
End Sub
I am using a Command button in my DB form to run this code, where a file name is pulled from a text box in the form, completing the link address. The problem is, I have no experience with access or visual basic! :( So, when my code gives me an error saying "Sub or Function not defined" and highlights my OpenDocument function, I am at a loss of what to do. Since I am unfamiliar with what type of function OpenDocument is, I dont really know how to define it.

I am running Access 2000 btw.
 
OpenDocument is not a built-in function of Access VBA.

That function would be a user defined function and contain the Shell command that actually opens the document along with some other code to test that it actually exists and the messages displayed to the user when it doesn't.

The code you found should have a definition of the funtion also included in the post. Go back and check it out. You have probably just overlooked it. Post a link to the original thread where you found it if you need more help working out which parts are required.
 
Ok, that is helpful. I checked the original location I found the code but it doesnt say anything about defining said function. Here is the link, and look at the first response to the thread question. (you will have to copy and paste the link casuse the forum wont let me paste links until ive made 10 posts) access-programmers.co.uk/forums/showthread.php?t=203251&highlight=embed+jpeg

and btw, i have already asked the original poster to clarify but he hasnt yet responded.
 
I actually found a perfect thread and that code worked great! With a few modifications for my personal file configurations, it worked without a hitch!

heres the address if anyone else is having difficulty solving this problem. access-programmers.co.uk/forums/showthread.php?p=1147170#post1147170

(I cant post links yet cause i dont have 10 posts :()
 
Well done. Welcome to the world of coding. It is a small step but do try to understand how that code works and you will be soon on your way to achieving some of the incredible variety of actions that can be done in code.
 

Users who are viewing this thread

Back
Top Bottom