pictures to go with the database

QuantumCat

Freshman
Local time
Today, 08:38
Joined
Oct 25, 2004
Messages
26
I am making a simple database, so no worries there, but I want to ad pictures to it.

for instance, you make a facepic database of all the people you know, you'd want to create a picture box in my form and if I add a person then add the picture.

How do I go about that?

QC

PS: I tried adding a picture, but that isn't a dynamic picture. if I add a picture I add it at design time, whilst i want a frame to which I couple a picture during run-time
 
Last edited:
Come to think of it...

How do I path-relate this?

Does Access store these pictures en-full in the database?
Does Access autamatically refrence it to it's own directory?
(analogue to app.path in VB)

QC
 
Never done this, and there might be better methods. You could try.

Store all the filepaths in a table. So a textbox bound to that field in a form which displays the filepath. Make the visible property to No.

Add an image which links to a image. Then on the onCurrent Event out the following code :

Code:
Me.ImageName.Picture = Me.textboxname

This will change the link of the image to the stored filepath.
This should change the picture when you travel through the recordset.

Hope this helps

Andy
 
it gives me an idea ... but not quite, I an very noob at Access.
so I can understand what you say - but it leaves me with a lot of questions.

First of all, the only control that holds a picture is one I have to choose a photo right away -thats the "image" control (curse all translations, I have a Dutch translated version)

Okay -so I add a dummy version and then ...?

The on Current event does what?

How do I work with it?

Does it work like the lost focus function or event?
 
The Form_OnCurrent event 'fires' when the underlying recordset changes by some action of yours. Selecting a new record by navigation controls, using the UNDO operation, or updating the record in the recordset are the most likely triggers for the event.

In the sense that _OnCurrent, _LostFocus, and _GotFocus are all events, then yes, they are alike. But for different events.

spacepro says he's never tried the solution he suggested. But I have. It works like a champ. You must determine the name of the picture file and store that in the table that will drive your picture process.

Some of the other attributes of an image control are how it tiles (You don't want it to tile, probably), whether it can zoom (You might want that, because it will adjust picture size to match the control you allocated), and whether it has to maintain aspect ratio (which personally I think is a good idea, but that's just me.) Play with it. However, do not embed the picture in your DB. That's another option and you DON'T want that one. It leads to database bloat.
 
thanx, but can you show me some codes for lost focus and such
I am very acquainted with VB but in VBA in Access I feel a little lost.

one of the reasons I do consider embedding the picture is to make the database/pictures independent of the location, but there are other ways around that problem.
 
Embedding your images is not a good idea, as per The Doc Man's comments.
It would be quite easy to have a specific folder, thats holds the images that could be packaged with the db when you install it in your environment, otherwise you will have problems with your db later on.

I have attached a sample db that shows how the images can change per record.

Open the table tblNames and change the filepaths in the Imagepath Field to two images on your PC (make sure they are Bitmaps - .bmp).
Then open the form frmPersonnel and scroll through to the next record to see the image change.
If you go to add a new record or don't change the filepaths before viewing the form, you will get one of two error messages. Either Can't find file or Invalid Use of Null, this is because the textbox displaying the path is empty.

This is just to give you a starter and an idea on how it works.
Play with it and if you have any further questions then please post.

HTH
Andy
 

Attachments

hey thanks, it's great! thanx again

One thing:
How do you turn it into a relative path?
I can't seem to get app.path working :-(
 
QuantumCat said:
Can the picture frame autosize itself?

sorry 'bout that, got it.
the dutch translation says (translated) cropped, stretch, don't stretch.
it's not auto-size bit don't stretch does what I want it to do.

( really hate these translations, even though it is Dutch, it is isn't a 1-on-1 unambiguous meaning, but then again, i'm not a dummy that needs a Dutch translated version, so I don't think like a dummy that needs a Dutch translated version , I mean in Excel old Lotus commands used to work, not anymore, even worse: the Dutch translation doens't understand the universal English commands!!!! sigh- sorry 'bout that, I needed to vent my frustrations. Thank you for "listening" (=reading) )
 
Last edited:
spacepro said:
I have attached a sample db that shows how the images can change per record.
Andy

I changed my database by adding columns to the database hence I deleted my form and created a new one through the form wizard.
NOW, I seem to have a problem in creating the right form/module to make the code you supplied worl... so it doesnt work (anymore) can you help me.
I I have uploaded my database, it's not for you to do it, but I think it' seasier for you to see what the problem is. If you can figure out how I can
lose all the class-modules supplied by the wizard and create my own (with the code you supplied) I'd be much obliged.

Thanx

QC
 
QuantumCat said:
I have uploaded my database
Thanx

QC

i can't upload it, it's too large no matter how I trim it 128K, one entry,two columns, no embedded pics).
 
Last edited:
spacepro said:
Have you tried Compact and Repair from the Tools Menu.
Otherwise email me the db to access@spaceprogram.co.uk.

Andy

Thanx, I will

By the way, I circumvented the problem by using a baclup of the working form and adding the controls and setting the relations manually, however,
I still want to know what I am doing wrong in the "other" version
 
sorry -no go -did something stupid,
changed the picture and it went from
630 kb to 14Mb
I changed the picture to <none> and it's
still 14Mb :confused:
 
QC,

Try deleting everything that doesn't apply to the problem, then compact and repair and then zip it up. Let me know if the filesize is reduced.

Andy
 
spacepro said:
QC,

Try deleting everything that doesn't apply to the problem, then compact and repair and then zip it up. Let me know if the filesize is reduced.

Andy

just the compact and repair was what it needed, thnx
I havv zipped it and I have sent it your ways.

Thanx again

QC
 
QC,

I have had a quick look. If you go in design view on your form and click on the next to the Oncurrent and Onload events , which opens the VBA Editor and copy the code in the class module to the relevant events and that should do the trick.

Let me know if it works.

Andy
 
Junt one thing: how do I get a relative path in there?
I use fixed path now, but I want to be able to copy/move the database
without having to change all (path) entries

is there something like app.path?
 

Users who are viewing this thread

Back
Top Bottom