Maximation
01-25-2005, 08:14 PM
Hi,
I am hoping someone out there has run into this problem and has some insight. :o
I have a directory with very small images around 48x36 pixels each. I am trying to fill an image table with about 900 images from this directory. The image table has two fields, one is a unique keyed field and the other is the OLE Object. The images are linked and their names are the same as the number in the keyed field (i.e. keyed field: 0000766 Image file: 0000766.gif).
Currently I have to select the OLE Object field and then right click and select "Insert Object", then click "Create from File" then check the "Link" box and finally browse to the actual image and select "OK". This is taking forever....
Is there a way to write some code to auto fill this OLE Object field based on what I type in the keyed field? Or just some code to run once in a while to fill in the blanks? :confused:
I will be adding and removing records to this table in groups of about 20 to 50 a month and I have a requirement to view them in a continuous form.
Any help would be greatly appreciated!! :o
Thank you.
PS - I originally posted this in the "Forms" section, but it may really be a "Tables" issue...
Link to post in "Forms": Image Table Population Question (http://www.access-programmers.co.uk/forums/showthread.php?t=79615)
Len Boorman
01-26-2005, 04:17 AM
Rather than use an OLE could you use a Hyperlink
Use a query to update the hyperlink field with the full path and the file name
and enclose the whole lot in #'s. believe me they are required.
so you end up with a hyperlink #c:\whatever\000007.gif# except you will not actually be able to see the #'s
len
The_Doc_Man
01-26-2005, 07:30 AM
It is possible to write some VBA code to search a given directory path. The more predictable you make the total specification, the better off you are. Like, put all files in a single directory/folder.
Look up the following topics in your Help files before starting this.
FileFind object (or is it FindFile? I'm shooting from the hip here.)
Image controls (to see properties)
In VBA code that you could run in response to a button click, you might be able to do a FileFind for a wildcard filename, specific file type, and specific file path. So what you do is, you define the wildcard spec, then execute the FileFind. Part of the object is a property that happens to be a collection of the file specs found when you executed the search. So you can do a
For Each fspec in ffobject.FilesFound....
Next fspec
The elements of the .FilesFound collection are full file specification strings. They reference file names that were found during the execution of the search implied by the FileFind object.
Now, inside that loop, you would have to do a DLookup on the file spec to see if you already have this file in your DB. If you do, you have nothing to do. If you don't, you can add a new record to a recordset that contains this reference. When you reach the end of the loop, you are done.
Now.... a couple of wrinkles you can add for giggles...
Add a yes/no field to your table. Call it "StillThere" or something similar that is consistent with your naming convention. Before you do the FileFind, run an update query to reset all "still there" flags to "NO" - meaning, not there any more.
Now, inside the loop, instead of just ignoring the files for which the DLookup found something, you can update the StillThere flag to "YES" for the record containing that reference. And, of course, you would obviously create the new records with their "StillThere" flags initially set to "YES"
When you are done with the loop, delete all records that are not still there! Complete table maintenance, one-touch updates.
As to how this would work in continuous forms, I've never tried it, but for individual forms, all you need to do is fire an OnCurrent event for the form and load this spec to the .Picture property of the image control. No hyperlink or OLE object needed. You might have to experiment with this 'cause I don't know what you'll get on continuous forms. I suspect you will get the image control as a blank/empty on each row until the first time you make that row become the current record. After that, your guess is as good as mine.
Maximation
01-27-2005, 01:45 AM
Hi,
LEN -
I tried testing the Hyperlink idea, but could not come up with a way to get the links to display as pictures in my continuous form. I did show the links though. I believe in order to display the images in a continuous form, I have to use a bound object, otherwise, I get the same image displayed on ever record. Maybe if I could get the Hyperlink into the bound object. I haven't found out how to do this yet. :confused:
DOC MAN-
I see where you are going with the FindFile Object and .FilesFound. This is a good way to get the full path.
The only problem I have with this is that I can't use the Image Control in the continuous form because of it not being bound to the records individually. I get the same image on each record, instead of a unique image for each record.
I tested your ideas out with a Forms "bound object", but I could not find the collection of the bound object to put the path in. :confused: The way you have suggested is very close to being successful, if only there was a way to input the directory path information into the bound object. :confused:
Thank you both for your input and help. :)
Here is some more info that might help clear things up a bit....
I have a products table that has a many-to-one relationship with the image table that has an OLE Object. I have a requirement to display the products table in a continuous form that uses about 10 seperate filters buttons to search with. The form needs to have the features for an employee to quickly glance at the page and see the image of the product they are searching for, without having to do much text scanning and/or reading of the descriptive information.
I already have all this working fine, but the maintenance behind the scenes is not working due to too much overhead with the "OLE Object/Image Object" manual input.
Thanks again for your time and input.
The_Doc_Man
01-27-2005, 09:03 AM
if only there was a way to input the directory path information into the bound object
Search this forum for discussions of the "Common Dialog" control (or COMDLG??.OCX or .DLL, which is the file's name) as an ActiveX control or as a callable external function. Pat Hartman posted something on that well over a year ago.
This Common Dialog control lets you do the "Browse" function that shows you folders and you can pick a file, navigate folders, etc.
Then when you are done browsing, it returns a string for the name of the file you selected. The path is merely everything returned by the Common Dialog control from the beginning of the string to the LAST "\" character in that string, including the "\"
I get the same image on each record, instead of a unique image for each record.
I did express my misgivings about that. Continuous forms behave very much differently from single forms. But if you search the "forms" portion of the forum, there was something posted about "conditional formatting" that was supposed to address this issue on continuous forms. I've never had the need to play with myself so all I can do is mention the possibility that you could find some answers there.
but the maintenance behind the scenes is not working due to too much overhead with the "OLE Object/Image Object" manual input.
Yeah, no "DUH" there. OLE is possibly the most expensive method of pulling in an image. My method doesn't help but I can assure you, if the conditional formatting stuff helped, my method would be the fastest.