VBA code and Images

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am creating my first ever database for an assignment.

It is on movies. I want my database to display an image of each actor on
every page. I thought I would try and do this using some VBA code.

I have got all the images I want to use in a folder on the desktop (they are
all jpegs).

Any help would be really appreciated
Thanx
 
Hi Fi,

Need more info about what you are trying to achieve here.

first, what is a "page" - do you mean a record displayed on a form?
Should these images be randomly chosen?
Are they displayed as decoration, or do you want to them to be to be
stored as part of an actors bio and displayed in context?

Here's what's in my head -
in you db design, you have a table for movies, one for actors, one for
directors, genres, etc. each logically linked with the appropriate
relationship
In your actor table you will have an "ole" field where you can store
the photo for each actor. you may chose to have a seperate table for
photos so you can have more than one photo for for each actor - depends
on how big you want to make this thing.
when you create a form, bound to the table with the photo field, the
field can be populated one record at a time by double clicking on the
control in normal view.

but note - using jpegs greatly increases the size of an access database
and slows it down no end. So use very small jpegs. also ole (object
linking and embedding) is a huge topic in itself... and i'm not an
expert - you will probably want to search the newsgroups for more info
on it before you proceed!

hope that helps
 
Sorry for being unclear.
Basically what you suggested was what I was trying to do. However I read in
Access Help that instead of using an OLE to link the correct pictures VBA
code could be used amd this is better for jpegs and reduces the database size?

However it was unclear to me how exactly I do this. It has stuff about
pasting on to a module and making a table - but this is as much as I
understood!
 
I havent looked at access help since they dumbed it down in a2k, so i'm
not sure what's being driven at here...

but what it could be is this:
use a simple text field to store the address path of an image
(me.txtPicturePath = "C:\Pictures\Brad.jpg")
use the "On current" event of a form to trigger access to set the
"picture" property of a picture frame to the path each time a new
record is opened
(me.Image1.Picture = me.txtPicturePath.Value)
....that way nothing gets linked or embedded.

it's relatively simple in concept - but in practice it could get tricky
if you want users to be able to update the picture!
- You will need to make a call to the windows API to open a windows
"open dialog" for the user to select the picture
- which will return the path
- which in turn you will assign to the (hidden) txtPicturePath text box
(bound of course to the underlying actor table)
- and then refresh the image picture property...
do-able, but could get messy to do it this way for your first DB
outing...

Also be careful how this assignement is handed in - the db will now be
dependent on your computers file directory and a system of absolute
paths... not good if teacher says burn to disk and hand up tomorrow.
 
Fi said:
Sorry for being unclear.
Basically what you suggested was what I was trying to do.
However I read in Access Help that instead of using an
OLE to link the correct pictures VBA code could be used
amd this is better for jpegs and reduces the database size?

However it was unclear to me how exactly I do this. It has
stuff about pasting on to a module and making a table - but
this is as much as I understood!

The sample imaging databases at http://accdevel.tripod.com illustrate three
approaches to handling images in Access, and the download includes an
article discussing considerations in choosing an approach. Two of the
approaches do not use OLE Objects and, thus, avoid the database bloat, and
some other problems, associated with images in OLE Objects.

If you are printing the images in reports, to avoid memory leakage, you
should also see MVP Stephen Lebans' http://www.lebans.com/printfailures.htm.
PrintFailure.zip is an Access97 MDB containing a report that fails during
the Access formatting process prior to being spooled to the Printer Driver.
This MDB also contains code showing how to convert the contents of the Image
control to a Bitmap file prior to printing. This helps alleviate the "Out of
Memory" error that can popup when printing image intensive reports.

Larry Linson
Microsoft Access MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top