By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,709 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,709 IT Pros & Developers. It's quick & easy.

How to display multiple pictures per record in an Access database?

P: n/a
I want to store and display (on a form or a report) multiple pictures
per
record in an access database. The pictures are not stored within the
database. They are stored as files and the database contains the paths
to the
pictures.
The database consists of two tables:

TABLE DATA
ID Name LastName

TABLE PICTURES
ID Path

I want to create a form displaying data for each record of TABLE DATA
and
all the pictures (let's say aligned horizontally) for the particular
record
from TABLE PICTURES (ID <-> ID). MS Access allows subforms to be added
to a
form, but this doesn't solve the case, since subforms can be only
displayed
in data sheet view.

Nov 13 '05 #1
Share this Question
Share on Google+
12 Replies


P: n/a
"Wadim Grasza" wrote
I want to store and display (on a form
or a report) multiple pictures per record
in an access database. The pictures are
not stored within the database. They are
stored as files and the database contains
the paths to the pictures.
The database consists of . . .
I want to create a form displaying data for
each record of TABLE DATA and
all the pictures (let's say aligned horizontally)
for the particular record from TABLE
PICTURES (ID <-> ID). MS Access allows subforms to be
added to a form, but this doesn't solve
the case, since subforms can be only
displayed in data sheet view.


Where in the world did you get the idea that they can ONLY be displayed in
datasheet view? The wizard creates that, by default, but you can certainly
set the Source Object of the Subform Control to a Form and display the data
in that Form within the Subform Control.

Unless you have a strict limit on the number of pictures, trying to align
them side by side could be problematical -- what happens when you have one
too many to fit on the line?

For reports, use a Query for Record Source, joining Table DATA and Table
PICTURES, use the Sorting and Grouping properties to create a Group on ID in
Table Data and each picture as a "detail line" in the Detail Section.

A Form/Subform with single record view of a Form in the Subform control
might work will for the Form where you enter / edit data.

Here's some additional information: 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

Nov 13 '05 #2

P: n/a
Amazing, asking exactly the same question again with exactly the same
misinformation. It is NOT true that "subforms can only be displayed in
datasheet view". I'm not sure if it was here or in another newsgroup where I
answered your question. I suggest you visit http://groups.google.com, search
for the original posting, and review the answer there.

Larry Linson
Microsoft Access MVP

"Wadim Grasza" <Wa**********@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I want to store and display (on a form or a report) multiple pictures
per
record in an access database. The pictures are not stored within the
database. They are stored as files and the database contains the paths
to the
pictures.
The database consists of two tables:

TABLE DATA
ID Name LastName

TABLE PICTURES
ID Path

I want to create a form displaying data for each record of TABLE DATA
and
all the pictures (let's say aligned horizontally) for the particular
record
from TABLE PICTURES (ID <-> ID). MS Access allows subforms to be added
to a
form, but this doesn't solve the case, since subforms can be only
displayed
in data sheet view.

Nov 13 '05 #3

P: n/a
I am absolutely sure that your amazement will be deemed after you learn
that this question was asked in multiple groups simultaneously.
Nevetheless, no-one seems to competent enough to solve another problem
that I have posted in the newsgroups, which is: how to display multiple
(the number may vary) images per record on an Access form or report
HORIZONTALLY.

If anyone knows the solution, please respond.

Nov 13 '05 #4

P: n/a
"Wadim Grasza" <Wa**********@gmail.com> wrote
I am absolutely sure that your amazement will be deemed after you learn
that this question was asked in multiple groups simultaneously.
Were you this rude in all of them?
Nevetheless, no-one seems to competent enough to solve another problem
that I have posted in the newsgroups, which is:
Either that or nobody was impressed by your approach
how to display multiple
(the number may vary) images per record on an Access form or report
HORIZONTALLY.

If anyone knows the solution, please respond.


I'm sure several people do.

Here's one way:

1. Create a form with the maximum hard coded image controls in the layout
you want.

2. Iterate through your fields in code and set the image's photo property
to the filed text (which I assume contains only a photo name)

While the following is not exactly as you want, the principle is the same -
24 image controls are laid out (actually on a 6-page tab control), and named
img1 through img24, and filled and made visible if a photo record exists.
In my case, I've already controlled for the max limit of 24 photos when I
created the records.

Dim c As Integer
Dim i As Integer
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset

DoCmd.Echo False, "Fetching Photos"
c = 0
With rs
.Source = "SELECT photo_name FROM photo WHERE photo_off_id=" & id
.Open , CurrentProject.Connection, adOpenKeyset, adLockOptimistic,
adCmdText
Do While Not .EOF
If FileExists("C:\photos\" & .Fields(0)) Then
c = c + 1
Me("img" & c).Picture = "C:\photos\" & .Fields(0)
Me("img" & c).Visible = True
End If
.MoveNext
Loop
.Close
End With
DoCmd.Echo True

--
Darryl Kerkeslager

Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
See www.adcritic.com/interactive/view.php?id=5927
Nov 13 '05 #5

P: n/a

"Wadim Grasza" <Wa**********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I am absolutely sure that your amazement will be deemed after you learn
that this question was asked in multiple groups simultaneously.


I am amazed that someone so incredibly self-assured would not have known
that multi-posting is incredibly irritating to people who provide answers,
and that cross-posting (that is, listing all the newsgroups in the same
post) will result in followups (answers and additional dialog) will appear
in all the newsgroups, so that the threads will not diverge. For other good
suggestions on effective use of newsgroups, see the FAQ for this newsgroup
at http://www.mvps.org/access/netiquette.htm.

Frankly, at this point, I am not sufficiently motivated to give you an
additional answer to go and google to see all the exchanges in those
multiposted newsgroups. If you'd care to carefully review your question, the
answers, and clarifications you have made and start a new thread, perhaps
someone will have an answer for you.

You significantly decrease your chances of getting the answer you need when
you make it difficult for the potential responders and when you respond
defensively to irritate them.

Larry Linson
Nov 13 '05 #6

P: n/a
Thanks for your help.

I'm still looking for a solution because this one creates a limited
number of image controls. My objective is to have the number of image
controls not limited.

Thanks again.

Nov 13 '05 #7

P: n/a
To respond to your message: I appreciate your advice. This message has
been sent to one group only so there will be no 'exchanges'.

After reviewing my question, the answers, and clarifications the
following should clarify my problem lastly: How to horizontally display
multiple (number not limited) images per record on a form or a report?

Nov 13 '05 #8

P: n/a
"Wadim Grasza" <Wa**********@gmail.com> wrote
I'm still looking for a solution because this one creates a limited
number of image controls. My objective is to have the number of image
controls not limited.


I suppose you could count the images to be created, open the form in design
view, dynamically create the image controls, then proceed ... but what a
pain in the butt for users to use a form that would scroll horizontally
forever.

--
Darryl Kerkeslager

Power corrupts.
Absolute power corrupts absolutely.
Knowledge is power.
See www.adcritic.com/interactive/view.php?id=5927
Nov 13 '05 #9

P: n/a
This might be a good solution. But please notice that the image
controls have to be created on the OnCurrent event, because the number
of images and the images themself differs depending on a record. I
don't know if it's possible to switch to Design mode, while on the
current record, create some controls, and then go back to Form View
mode. And event if it's possible, is it optimal? I wish controls could
be created in Form View mode.

Anyway, thanks for the suggestion.

Nov 13 '05 #10

P: n/a

"Wadim Grasza" <Wa**********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
To respond to your message: I appreciate your advice. This message has
been sent to one group only so there will be no 'exchanges'.

After reviewing my question, the answers, and clarifications the
following should clarify my problem lastly: How to horizontally display
multiple (number not limited) images per record on a form or a report?


What determines the number and which images. If you will describe the
Record, someone might be able to help. If the path-and-filename of the
images are held in a related Table, one per Record, you can do what you
want; if the image-path-and-filename are held in multiple text fields in the
same Record, you can do what you want (but that would imply a limit). You
will have to know the maximum number of images so you can preset Image
Controls -- fill the Picture property of the ones you want to display; set
the Visible property of the others to False.

Larry Linson
Microsoft Access MVP
Nov 13 '05 #11

P: n/a
Thanks for your help.

The dataset contains two tables: T_PEOPLE and T_PICTURES.
T_PEOPLE has the following columns: ID, Name.
T_PICTURES has the follwing columns: ID, PersonID, Path.

The database contains a form named F_PEOPLE. The datasource of the form
is T_PEOPLE table.

I want the F_PEOPLE form to dislpay all the pictures from the query:
SELECT * FROM T_PEOPLE INNER JOIN T_PICTURES ON CurrentID =
T_PICTURES.PersonID, where CurrentID is the ID of the current record on
the form.
I would like to display the images horizontally. I would also like to
have the number of displayed images not limited.

Naturally, the number of images should be constrained at some point,
but I feel that it's more elegant if it is not constrained at this
point. I would like to have the possibility to display unlimited number
of images. I have a rather foggy idea on MS Access architecture, but,
as a programmer, I think that if not being able to create controls in
Form View mode is for a reason, there are other ways to achieve the
aimed goal (limiting recursive calls or security or the general idea
etc.), othen than keeping programmers off creating controls in Form
View mode. Since I'm still a student, my knowledge and reasoning might
not be as deep and thorough as they should be in order to understand
the grounds of the restriction. However, I would like to know these
grounds. And I would also like to see a way to achieve my goal.

Thanks for your response,

Wadim Grasza

Nov 13 '05 #12

P: n/a
Correction: I want the F_PEOPLE form to dislpay all P pictures from the
T_PICTURES that satisfy the following condition: P.PersonID =
currentID, where currentID is the ID of the current record in F_PEOPLE
form.

Nov 13 '05 #13

This discussion thread is closed

Replies have been disabled for this discussion.