I must have virtually every manual written on Access, but none it appears actually cover inserting pictures into a form. A friend has asked me to write a database for his client base. He owns a small dealership that sells high-end value cars.
The database is no problem it is the usual stuff. He wants to be able to insert a jpeg/bitmap on every form that describes a specific car. If he is selling a Jaguar, he wants of the car to appear whenever he searches for that car, together with its description.
How do I insert a jpeg/bitmap into a form. I have been through most of the help procedures in 2007, but none actually work. Or is it just me?
To start with within your Form specify the File Name of the image.
As an example you use a Unique Identifer within the Record, lets take Jaguar and Lexus For simplicity I'm ignoring moodel. So a corresponding image should be available for these two records one should be jaguar.jpg and the second lexus.jpg. I keep an image flag so that everyone can see it a image is available or not. Then on the Form onCurrent:
Dim FullPath As String
FullPath = GetImageDir & .[Image File]
If Dir([FullPath]) <> Empty Then
.[ImageControl].Visible = True
.[ImageControl].Picture = FullPath
.[ImageControl].Visible = False
I do not embed images a database. The GetImageDir is the path of the directory holding the images and declared in a separate Function.
May I thank both of you for taking trouble with my request. Now my friend wants to be able to Preview a Report that contains six jpegs of each car. Is it possible to assign a Report to a Record? If so, the user would be able to Preview the six jpegs and then print the Report of the car if they wish. Please remember that I am returning to Access after a four-year gap and am very rusty
If you're absolutely certain (who ever can be?) that there will never be more than six picture for one single car, the quickest, easiest way consists in having six columns in the cars table, each containing the full name of a picture file pertaining to a car.
A far more canonical approach implies the use of two tables. The first (main) table is the cars table. It contains data about a car. A second table (pictures) consists in two columns (at least): one column contains the name of a picture and a second column, often named foreign key in the relational databases management system theory, contains an identifier that relates each row if this table to a row in the main table. Both tables are linked by a one (cars) to many (pictures) relationship (i.e. a car can have more than one picture and, if you enforce relational integrity, each picture must be related to a car. That way, each car can have any number of picture(s).
You normally build a query joining both tables to process the results and use them in a form or in a report. e.g.
SELECT Tbl_Car_Data.*, Tbl_Picture_Data.*
FROM Tbl_Car_Data INNER JOIN Tbl_Picture_Data ON Tbl_Car_Data.CarID = Tbl_Picture_Data.CarID
Here the column CarID of the Tbl_Car_Data is the primary key (unique identifier) of this table, while the column CarID of the Tbl_Picture_Data table is the foreign key linking each row of this table to one row in the Tbl_Car_Data table.
Such queries can be used the same way you would use tables but, specially in case of a report, you can use built-in grouping functions to have a report present, in your case, a page containing the information about a car plus every picture of this same car (provided the page is large enough, of course!).
Now the client has agreed that one picture (jpeg) of each car will be sufficient. At the present moment, I am entering the jpeg file name for each car in the Picture field of each record relating to a specific car. Then I have a command button that loads the jpeg when the client clicks on the button. But how would I embed a jpeg into the form so that as I scrolled through each record, there would be a small picture of the car, without the need to click on a command button?
You would need to build the path in the form query source and assign the value of path property of the picture control to that. Since you can't toggle the visibility, I would have the form display a generic "No Image Available" image in the event that there is no image to show.