Adding Photographs to a database table from a form (follow up ques

G

Guest

Hi,

I've created an 2003 student infomation database. I've built the student
input form and student "picture" id report. But I'm having problems adding
the photo paths to the student table from the input form. I've followed Roger
Carlson's sample called "PicturesLoad.mdb" which illustrates how to do this.
However, an error message comes up stating "sub or funtion not defined". Then
highlights the "ahtAddFilterItem" item in the line below.

strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")


My main purpose for this piece of the database is to print student picture
id cards. The student pictures do not necessarily need to be shown on the
form. I personally have litte VBA code experience. My husband uses VBA in
Excel often and has been helping me through this.

Any help is appreciated! Thanks in advance.
 
G

Guest

Did you import the module named "modOpenSaveFile" from Roger's sample? This
module contains several functions written by Ken Getz, one of which is the
"ahtAddFilterItem" function. After importing this module into your database,
open the module in design view. Then click on Debug > Compile ProjectName,
where ProjectName is the name of your VBA project (likely the same as your
database name, but it doesn't need to be).


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
M

maurrieske

You can use the properties(3) of the picure to change the link to the file.

First you make a table with 2 columns and name it "Student_picture".
1th column is the student number (I mean the key column in the student
table). Name this column "name".
2nd column is the full path to the picture file included the filename (for
example "c:\students\photo\student_001.jpg". Name this column "path"
Now insert e few records with real links to real picture files.
This way you have a table where alle the links to the pictures are stored.

Now you make form (with the name "frm_student_id" with a combobox (name is
"cb_01") that is linked to the this table. The combobox has 1 column. Only
the keycolumn.
Then you insert a picture and name it "photo_01". The picture you insert is
"c:\students\photo\student_001.jpg" (make sure the file excists)
Even insert a button and name it "btn_01"

Naw make a report with the name "rpt_student_id"
On this report you insert a picture. The picture you insert is
"c:\students\photo\student_001.jpg" (make sure the file excists). You name
the inserted picture also "photo_01"
You may insert other items in the report (such as name, student number)


Then put the following code on the codepage of the form

Private Sub cb_01_BeforeUpdate(Cancel As Integer)
Me.photo_01.Properties(3) = DLookup("[path]", "Student_picture", "[name]="""
& Me.cb_01 & """")
End Sub

Private Sub btn_01_Click()
DoCmd.OpenReport ("rpt_student_id"), acViewPreview
End Sub


And put the following code on the code form of the report

Private Sub Report_Open(Cancel As Integer)
Me.photo_01.Properties(3) = DLookup("[path]", "Student_picture", "[name]="""
& _
Forms("frm_student_id").cb_01 & """")
End Sub

This way if you open the form and select a student in the combobox, the
picture will be shown in the form. And if you click the button, the report
will be opened containing the correct picture.

What you were looking for is the propertie "properties(3)" in the code.
Using this propertie you can change the picture, for this is the propertie
that containes the fullpath and picturename.

Greetings and good luck,

Maurrieske
 
G

Guest

Thanks Tom! My husband went back and added the module, and with a few
adjustments it worked great!. I then added the form as a subform to my main
student input form.

We are also attempting to create student id cards (a lable/report with 10
student id cards to a page, all showing different students and their
pictures). I've created the report with all the details that we need, but I'm
not sure how to bring all the different picture into the report. We've looked
at other postings, but just can't make sense of it all.

By the way, we are a small co-op homeschool with 110
students..............so not the 1000 records, as in another posting! But we
still need to track their info the same way!

Again, any and all help is appreciated. Thanks in advance.
 
G

Guest

I have an ImageDemo sample that includes displaying pictures in a report. You
are welcome to download a copy here:

http://home.comcast.net/~tutorme2/samples/ImageDemo.zip

The report is based on this KB article:

How to display images from a folder in a form, a report, or a data access
page
http://support.microsoft.com/?id=285820


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
G

Guest

Thanks again Tom. My husband wanted to know, do we use all the modules and
all the code behind the form? He tired a few things but it's not working. We
are taking a break from it tonight (or this morning Pacifice coast time).

Thanks,
 
G

Guest

There is VBA code in the Detail_Print event procedure of the report that
makes a call to a function named "DisplayImage". This function is found in
the module "basDisplayImage", so you will definately need that module. (I
suppose the alternative would be to incorporate the DisplayImage function
into the same class module for the report, but then it would only be
available to that one report. I you later wanted to create an alternate
report that also included images, you would need to duplicate this code if it
was self-contained, within the report's class module.

The module "basCalendar" is used with Access MVP Allen Browne's calender
functionality. You may have noticed a small calendar button on the
"frmEmployees" form. This functionality also requires the form "frmCalendar".
You can read more about Allen's calendar, here:

Popup Calendar
http://allenbrowne.com/ser-51.html

Access 2007 includes built-in calendar functionality for date fields,
however, they omitted the ability to scroll for different years.

You will need the module "basDetermineDriveType" only if you attempt to copy
the existing frmEmployees form into your database. My ImageDemo is still a
work in progress; it is not finished yet. There is VBA code that checks the
drive type that the selected image is saved to. This code is more intended
for a multi-user Access application, where you would not want the user to be
able to select an image from *their* local hard drive, because it would not
be available to other users. My future plans for this demo include building
an options form, where the user can select whether or not they want to allow
selecting images from a local hard drive, but so far I haven't built that
yet. If your database is a single user application, then there would be no
reason that you'd need to restrict the user from selecting an image from a
local hard drive.

The module "basDriveToUNC" contains VBA code to convert a mapped drive
letter on a file server to the UNC equivalent. This is useful for a
multi-user Access application, because each user would not have to have the
same drive letter mapped exactly the same.

The module "basWin32CommonDialog" is basically equivalent to the module
"modOpenSaveFile" found in Roger's sample. Like I said, my demo is still a
work-in-progress....I imported this module into my sample, but so far, I'm
not using it. The intent is to replace the call to:
Application.FileDialog(msoFileDialogFilePicker), found in frmEmployees, since
this code does not work in Access 2000. However, the API (Application
Programming Interface) method of calling a common file dialog (ie.
"basWin32CommonDialog" or "modOpenSaveFile") will work just fine in earlier
versions of Access.


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
G

Guest

Thank you very much for all of your help and suggestions Tom! Both issues we
were working on are now fixed! The pictures of the students show up on the
student id report page - all 10 per page! Wow, what you all know about VBA in
Access amazes me. My husband said he learned a lot too this weekend! Our
school Director will be very happy to not have to cut and paste to make id
cards this year! Thanks again.
 
G

Guest

You're very welcome. Glad I could be of help.

I invite you to download a zipped copy of a Word document that I call Access
Links. It is filled with lots of useful information that will help you on
your journey towards learning Access. For the present time, just concentrate
on the information shown in the first four pages, although skim the rest, so
that you'll know what is to be found.

http://home.comcast.net/~tutorme2/samples/accesslinks.zip


Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 

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

Top