Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADD PICTURE 2

Status
Not open for further replies.

FoxStudent

Technical User
Feb 24, 2000
85
GB
What is the code that is needed behind a command button to add a picture object to a record?

Thank u
Grainne
 
Are you trying to import it as an object or just display it through an image box?
 
Just a warning... If you are going to import an image into the database, be forwarned that this will increase the size of your .MDB greatly. From what I have been told, it is usually better to save a path to the file that is stored on a hard drive.

I haven't tried it any other way, so I can't really help with the code... Good luck... Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
Email Message from FoxStudent:

Subject: add picture

Thank u for the advice I had noticed that the database was getting
very large before it got corrupted. So what do u suggest I do, have a
text field in order to store the address and then allow the user to
click on a button if they want to display a picture for a given
record. The only reason I suggest using a button instead of coding
into a form method is to allow the user to browse records faster. If
so how would I allow a user to first save the address and secondly
display the picture at that address?

I am sorry for the bother I am probably just a way out of my league.
I am a student doing a BEng Honours in Software Engineering who is
trying to make a bit of extra cash.

Thank u
Grainne
Ireland

Grainne,

The button idea sounds like a good idea. I had a personnel database that had room for a small picture of the employee. I created a sub-directory below the database and put all of the images in there. In the table where I stored the employee information, I had a field that had the complete path (C:\DATABASE_DIRECTORY\IMAGES\EMP01.JPG) of the image to display. I also created a "No Picture Available" image (black square image with words saying so) and would default the value of that text field to that. Because it was a small image, it loaded rather quickly, but your images may be larger, so I think the button could be a good idea.

I put an invisible button on the form the same size as the image. If the user wanted to change the image, they could click on it and using the ONCLICK event, I prompted them for the address of the new image file and stored that in the record. I would send you a copy of that database as an example, but that was at my last job and I don't have access to it any more.

Hope that helps. If you have any further questions, feel free to ask, but please post them to the forum. The reason I ask this is that not only does this help you, but it may help someone else with the same problem. Terry M. Hoey
th3856@txmail.sbc.com

Ever notice that by the time that you realize that you ran a truncate script on the wrong instance, it is too late to stop it?
 
In a related question, I have a table that contains information about products, such as the sku, and description. I would also like to add a field for a picture of the item. The pictures are already created and available in another folder on my computer. The pictures names match the sku. Example Item 1 sku = se9030, picture 1 file name is se9030.jpg.

How do I import all of the pictures into the existing table so that they are available by the database. There are over 1000 of them so importing one at a time is not an option.

Thanks
 
Importing over 1000 images would take a *HUGE* amount of space.

Why not have a couple of lines of code in the Form_Current event to display the image in an image box when a new record loads? I use this code to display mug shots on a form that displays ID information on prisoners. It assumes all the images are in the "f:\data\mugs\" directory, and is a little low-end, but it works every day, and don't have to import images or replace old pictures with new ones:

Dim sPath0, sFile0 As String
ImgMug.Visible = False
If id_Number > 1 Then 'if no ID number, then no picture
sPath0 = "f:\data\mugs\" & Trim(Str([Forms]![frmWarrantEntry]![id_Number])) & ".jpg"
sFile0 = Dir$(sPath0)

If sFile0 > " " Then
ImgMug.Picture = sPath0
ImgMug.Visible = True
Else
ImgMug.Visible = False
End If
End If
 
calian, thanks for the quick reply. I'm pretty new at Access. I understand the basic idea of your code but I'm not sure how to make it work in a form exactly. Could you explain a little more in detail? What is the Form_current event? Where does this code go to make it show the image?

Thanks,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top