Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: Images in Access

2 views
Skip to first unread message

Douglas J. Steele

unread,
May 26, 2005, 5:46:13 PM5/26/05
to
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.


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Andrew T" <And...@discussions.microsoft.com> wrote in message
news:FDAF7C0A-2C7F-4F2C...@microsoft.com...
>I have a file of jpgs that are listed by student number. They are in the
>same
> folder as the data base I want to use. I need to display the students
> picture
> (400+) and their name and other data. Is there a way these can be
> displayed
> without inserting each one in the table? I think I can build the form but
> am
> not sure how to get the picture and the student infomation to merge.
> --
> Just a simple school teacher trying to stay a head of his class


Andrew T

unread,
May 26, 2005, 8:58:02 PM5/26/05
to
Doug;

Sorry but you lost me. I did look at the sample but it is way above what I
understand. Access 2000 is what we are trying to use. We have all the student
pictures in one folder. I just do not want to spend several hours inserting
the locations in the table.

--
Just a simple school teacher trying to stay a head of his class

Stephen Lebans

unread,
May 27, 2005, 7:08:12 PM5/27/05
to
Hi Andrew,
I'm assuming you have a field in your table that contains the Student ID
#'s used to name the Jpegs. I'll also assume that you have a TextBox
control on your form that is bound to this StudentID field and is named
txtStudentID.
Place the standard Image(NOT Bound or Unbound Object Frame) control on
your form, name it ImagePhoto.

In the Form's Current event do something like:
Me.ImagePhoto.Picture = "C:\StudentPhotos\" & Me.txtStudentId & ".jpg"

Above assumes the folder containing the student photos is found on your
C drive and is named "StudentPhotos".

You will need to add error handling to allow for the situations where
there is no corresponding StudentPhoto for the current record. Generally
you would create a blank Photo containing the Text "Not Avail" or
something similiar. Use the DIR command to check for the existence of
the Student Photo and then load the Not Avail photo if no file is found.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Andrew T" <And...@discussions.microsoft.com> wrote in message

news:0DE067A0-A495-437E...@microsoft.com...

Andrew T

unread,
May 29, 2005, 11:18:02 AM5/29/05
to
I can not find the Standard Image Control. The only image control tool I have
only lets me insert a picture. Did I miss something? I did get the text box
to change when I selected another item. But the picture remains the same, and
to make it worse it is my vice principal. (He is a great guy though)
I have the table with the picture locations built. I used the help file but
the problem with the image control is something different.

Thanks for your patients.


--
Just a simple school teacher trying to stay a head of his class

Stephen Lebans

unread,
May 29, 2005, 11:31:22 AM5/29/05
to
There are three possible controls on your ToolBox that can display
pictures. As I stated in my first reply,

>> Place the standard Image(NOT Bound or Unbound Object Frame)
>>control on your form, name it ImagePhoto.

The control you want is named "Image". AS you hover your Mouse overtop
of the ToolBox controls it will show you the name of each control. I
honestly do not know what else to tell you
--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Andrew T" <And...@discussions.microsoft.com> wrote in message

news:C9B28FEF-7541-41D1...@microsoft.com...

Andrew T

unread,
May 29, 2005, 1:05:23 PM5/29/05
to
I have found the Image tool. Every time I select it we go to an insert area
and I have to select a picture? I have seen a icon for more controls but
there not controls that say standard image? Sorry I am so dense, thanks for
your replys and help.

Stephen Lebans

unread,
May 29, 2005, 1:25:21 PM5/29/05
to
Yes it is the Image control and you do have to initially select an Image
to load into the control. Just select your "Not Available" image we
discussed earleier. It does not matter for now.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Andrew T" <And...@discussions.microsoft.com> wrote in message

news:56B0D412-DDF0-4392...@microsoft.com...

luca

unread,
May 29, 2005, 1:36:51 PM5/29/05
to

"Stephen Lebans" <ForEmailGotoMy.WebSit...@linvalid.com>
ha scritto nel messaggio news:O3YJ3Dx...@TK2MSFTNGP14.phx.gbl...

Andrew T

unread,
May 29, 2005, 2:14:02 PM5/29/05
to
It did not work. I still have only one picture. The text box changes to
reflect the location of the student pictures but the picture does not change.
I already have the locations saved on the table, is there an easier way? It
was easy to use an update query and do that, but the picture is now the mess.
I still see the same picture and only the text box changes.

Thanks

Stephen Lebans

unread,
May 29, 2005, 3:44:35 PM5/29/05
to
So you have a TextBox control bound to the StudentID field and you can
see that as you scroll through t he records that the contents of this
TextBox display the proper StudentID?

Copy and paste all of the code you have in your Form's CLass module.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Andrew T" <And...@discussions.microsoft.com> wrote in message

news:2521BD32-E815-4546...@microsoft.com...

Andrew T

unread,
May 30, 2005, 12:37:21 AM5/30/05
to
Yes I have the complete path to the images on a table. Now all I need to do
is get the picture to be the same as the student number.

Stephen Lebans

unread,
May 30, 2005, 8:02:22 AM5/30/05
to
Where is the code behind your Form that I asked you to post?

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Andrew T" <And...@discussions.microsoft.com> wrote in message

news:AE1AEC10-4507-4A4C...@microsoft.com...

Andrew T

unread,
May 30, 2005, 12:52:07 PM5/30/05
to
Option Compare Database

Private Sub Form_Current()
Me.ImagePhoto.Picture = "C:\StudentPhotos\" & Me.txtStudentID & ".jpg"
On Error Resume Next
End Sub

I hope that this is correct. It runs but now the error messages says that
Access can not open the file C:\StudentPhotos\(a student number).jpg?
It then directs me back to the code page.

Stephen Lebans

unread,
May 30, 2005, 4:09:22 PM5/30/05
to
Well it sounds like the StudentID field is not returning a value that
can be linked to an existing Student Photo. When the Error is generated
you are placed back in VB IDE with the offending Line of code
Highlighted. Can you check the value of Me.txtStudentID? Is there an
exitisting photo that matches this ID?

Also we need to add error checking to allow for such conditions as "no
such student photo on file", etc. I'll dig something out of the NG
postings later tonight.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Andrew T" <And...@discussions.microsoft.com> wrote in message

news:622C3DEC-7E22-417D...@microsoft.com...

Stephen Lebans

unread,
May 30, 2005, 6:23:49 PM5/30/05
to
Let's add some logic to your function to handle the situation when there
is NO matching Student Photo for this particular StudentID. Erase what
you have in the Form's Current event and replace with the code below.

Private Sub Form_Current()

Dim sFileName as string

sFileName = "C:\StudentPhotos\" & Me.txtStudentID & ".jpg"

' See if this photo exists
' Returns a zero length string if file does not exist
sFileName = Dir(sFileName)

If len(sFileName & vbNullString) = 0 Then
' Load "Not Available" Photo
Me.ImagePhoto.Picture = "C:\StudentPhotos\NotAvailable.jpg"
Else
' Load the matching Photo for this StudentID
Me.ImagePhoto.Picture = sFileName

End if

End Sub

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


"Andrew T" <And...@discussions.microsoft.com> wrote in message

news:622C3DEC-7E22-417D...@microsoft.com...

Andrew T

unread,
May 31, 2005, 2:29:30 AM5/31/05
to
Stephen;
Thanks for the help. It is working. As I played with it I found that I had
to format the Student ID numbers so they matched. Some were only 3, 4, 5, and
6. I used an update query and the FORMAT command and gave the shorter ones 0
to make them 6 digits. That is the way the bar coder needs them so they have
been stored as 6. I also looked at using the same type of query to build a
text file with the picture location. It worked but has the same problem about
not having a jpg and trying to use a student number. I will work the error
statement out eventually. We will be using this for security at our
graduation in June. It has been a real help, I thank you again.
0 new messages