473,379 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Add photo to form/report

fnwtech
48
I have been reading the forums, but I really need a step by step. I took a one day vb class about 3 years ago, so I know just enough to be confused!

I have a database of students that I have to add photos to. In Access 2000, I had added them using the OLE field type. I can't seem to get Access 2003 to do this, even after installing Photo Editor. In my reading, it appears that using a text type and using a path or using BLOBs are better solutions. I can't seem to figure out either.

I would appreciate someone walking me through the steps.

I have a table for the images (though I have not imported them yet) named tblStudentPhoto with two fields, studentstateID and Photo. I had the photo field as an OLE but changed it to text. Should I type the path into this field? If so, do I start with the drive letter?
May 28 '08 #1
27 16009
nico5038
3,080 Expert 2GB
Check out these storing BLOB in Access links:
http://www26.brinkster.com/alzowze/home.asp
http://www.jamiessoftware.tk/article...ingimages.html

The first one even holds some fine access sample databases.

To insert an image in A2003 you'll need an OLE field and use the Insert/Object popup menu to store it. It does however take a lot of additional space and I would go for the "BLOB" solution.

Nic;o)
May 29 '08 #2
ADezii
8,834 Expert 8TB
I have been reading the forums, but I really need a step by step. I took a one day vb class about 3 years ago, so I know just enough to be confused!

I have a database of students that I have to add photos to. In Access 2000, I had added them using the OLE field type. I can't seem to get Access 2003 to do this, even after installing Photo Editor. In my reading, it appears that using a text type and using a path or using BLOBs are better solutions. I can't seem to figure out either.

I would appreciate someone walking me through the steps.

I have a table for the images (though I have not imported them yet) named tblStudentPhoto with two fields, studentstateID and Photo. I had the photo field as an OLE but changed it to text. Should I type the path into this field? If so, do I start with the drive letter?
Although not the most efficient Method, the simplest especially for a Newbie with limited VBA skills, would be to dynamically load the actual Photo Image into an Image Control on a Form at run time. This would require no storage of OLE Objects, and virtually no overhead. The only requirement would be to store the name of the Photo in a Text Field such as: BartSimpson.jpg, 209768871.jpg, etc. The code will take care of the rest and the Photos would remain external to the DB.
May 30 '08 #3
fnwtech
48
Although not the most efficient Method, the simplest especially for a Newbie with limited VBA skills, would be to dynamically load the actual Photo Image into an Image Control on a Form at run time. This would require no storage of OLE Objects, and virtually no overhead. The only requirement would be to store the name of the Photo in a Text Field such as: BartSimpson.jpg, 209768871.jpg, etc. The code will take care of the rest and the Photos would remain external to the DB.

What would be the code to add the photo to the image control?
Jun 2 '08 #4
ADezii
8,834 Expert 8TB
What would be the code to add the photo to the image control?
The code would be added to the Current() Event of the Form and would be similar to:
Expand|Select|Wrap|Line Numbers
  1. 'gPHOTO_PATH would be a Global Constant similar to:
  2. 'Public Const gPHOTO_PATH As String = "\Photos\"
  3. 'Photo Images would be stored in a Photos Directory under the
  4. 'Current Project Path
  5.  
  6. 'Can be set in the Properties Window of the Image Control
  7. Me![imgPhoto].SizeMode = acOLESizeStretch
  8.  
  9. If IsNull(Me![txtPhotoFile]) Then       'No Picture File, display no Picture
  10.   Me![imgPhoto].Picture = ""
  11. Else
  12.   'Picture File listed, but does the Path and actual File exist?
  13.   If Dir(CurrentProject.Path & gPHOTO_PATH & Me!txtPhotoFile, vbNormal) <> "" Then    ' it exists
  14.     Me![imgFieldInventory].Picture = CurrentProject.Path & gPHOTO_PATH & Me!txtPhotoFile
  15.   Else
  16.     'display some Error Message to the User
  17.   End If
  18. End If
Jun 3 '08 #5
wassimdaccache
222 100+
I have been reading the forums, but I really need a step by step. I took a one day vb class about 3 years ago, so I know just enough to be confused!

I have a database of students that I have to add photos to. In Access 2000, I had added them using the OLE field type. I can't seem to get Access 2003 to do this, even after installing Photo Editor. In my reading, it appears that using a text type and using a path or using BLOBs are better solutions. I can't seem to figure out either.

I would appreciate someone walking me through the steps.

I have a table for the images (though I have not imported them yet) named tblStudentPhoto with two fields, studentstateID and Photo. I had the photo field as an OLE but changed it to text. Should I type the path into this field? If so, do I start with the drive letter?

Hi

I think I am able to help you on this IDEA.

I designed a database that can navigate thought 11000 picture on access 2003 and it is working well.


The Idea is to save all pictures in a specific Folder. In my side I used the same root of my database in a folder named "Image". In your table tblStudentPhoto each studentstateID must have in Photo the name of his image.(JUST THE NAME AND DON'T FORGET THE FILE TYPE EXAMPLE image1.JPG) after that you have to insert an image place.
every time you want to navigate and see the picture that it is related to the studentstateID you have to write a small code.

your_image_place.image.picture=the root of you database + Photo

I can provide you many codes (OF COURSE THANKS FOR EXPERT PEOPLE IN THE SCRIPTS)to find the root of your database also to auto copy the image after choose it into the specific folder ...


WASSIM S DACCACHE
Jun 3 '08 #6
fnwtech
48
The code would be added to the Current() Event of the Form and would be similar to:
Expand|Select|Wrap|Line Numbers
  1. 'gPHOTO_PATH would be a Global Constant similar to:
  2. 'Public Const gPHOTO_PATH As String = "\Photos\"
  3. 'Photo Images would be stored in a Photos Directory under the
  4. 'Current Project Path
  5.  
  6. 'Can be set in the Properties Window of the Image Control
  7. Me![imgPhoto].SizeMode = acOLESizeStretch
  8.  
  9. If IsNull(Me![txtPhotoFile]) Then       'No Picture File, display no Picture
  10.   Me![imgPhoto].Picture = ""
  11. Else
  12.   'Picture File listed, but does the Path and actual File exist?
  13.   If Dir(CurrentProject.Path & gPHOTO_PATH & Me!txtPhotoFile, vbNormal) <> "" Then    ' it exists
  14.     Me![imgFieldInventory].Picture = CurrentProject.Path & gPHOTO_PATH & Me!txtPhotoFile
  15.   Else
  16.     'display some Error Message to the User
  17.   End If
  18. End If

So, I have tblStudentPhoto with two fields, studentstateID and Photo. I need to make Photo a text field with just the full file name of the photo. If I put the photos in a directory in the same directory as the database and name it photos, what part of the code would need to be changed to point to the photos?
Jun 3 '08 #7
wassimdaccache
222 100+
So, I have tblStudentPhoto with two fields, studentstateID and Photo. I need to make Photo a text field with just the full file name of the photo. If I put the photos in a directory in the same directory as the database and name it photos, what part of the code would need to be changed to point to the photos?
Put this code on a module
Expand|Select|Wrap|Line Numbers
  1.          Function GetPath()
  2.    'Returns the path to currently opened MDB or ADP
  3.    GetPath = CurrentProject.Path
  4. End Function
  5.  
then on your form on current action use VBA and write this code


Me.Image.Picture = GetPath() + "/photos/" + [tblStudentPhoto ]

Don't forget to add a picture on your form with a name "image"

wassim s daccache
CCE
Jun 3 '08 #8
ADezii
8,834 Expert 8TB
So, I have tblStudentPhoto with two fields, studentstateID and Photo. I need to make Photo a text field with just the full file name of the photo. If I put the photos in a directory in the same directory as the database and name it photos, what part of the code would need to be changed to point to the photos?
  1. In a Standard Code Module, place this Constant Declaration:
    Expand|Select|Wrap|Line Numbers
    1. Public Const gPHOTO_PATH As String = "\Photos\"
  2. In the Current() Event of your Form, place this code:
    Expand|Select|Wrap|Line Numbers
    1. 'Photo Images would be stored in a Photos Directory under the
    2. 'Current Project Path
    3.  
    4. 'Can be set in the Properties Window of the Image Control
    5. Me![imgPhoto].SizeMode = acOLESizeStretch
    6.  
    7. 'Name your Image Control imgPhoto
    8. If IsNull(Me![Photo]) Then       'No Picture File, display no Picture
    9.   Me![imgPhoto].Picture = ""
    10. Else
    11.   'Picture File listed, but does the Path and actual File exist?
    12.   If Dir(CurrentProject.Path & gPHOTO_PATH & Me![Photo], vbNormal) <> "" Then    ' it exists
    13.     Me![imgPhoto].Picture = CurrentProject.Path & gPHOTO_PATH & Me![Photo]
    14.   Else
    15.     'display some Error Message to the User
    16.   End If
    17. End If
  3. If you are still having trouble, I can make a Test Database available to your as an Attachment to better see what is going on. Just let me know.
Jun 3 '08 #9
fnwtech
48
  1. In a Standard Code Module, place this Constant Declaration:
    Expand|Select|Wrap|Line Numbers
    1. Public Const gPHOTO_PATH As String = "\Photos\"
  2. In the Current() Event of your Form, place this code:
    Expand|Select|Wrap|Line Numbers
    1. 'Photo Images would be stored in a Photos Directory under the
    2. 'Current Project Path
    3.  
    4. 'Can be set in the Properties Window of the Image Control
    5. Me![imgPhoto].SizeMode = acOLESizeStretch
    6.  
    7. 'Name your Image Control imgPhoto
    8. If IsNull(Me![Photo]) Then       'No Picture File, display no Picture
    9.   Me![imgPhoto].Picture = ""
    10. Else
    11.   'Picture File listed, but does the Path and actual File exist?
    12.   If Dir(CurrentProject.Path & gPHOTO_PATH & Me![Photo], vbNormal) <> "" Then    ' it exists
    13.     Me![imgPhoto].Picture = CurrentProject.Path & gPHOTO_PATH & Me![Photo]
    14.   Else
    15.     'display some Error Message to the User
    16.   End If
    17. End If
  3. If you are still having trouble, I can make a Test Database available to your as an Attachment to better see what is going on. Just let me know.
OK, I get where to put #2 and think I am set on that. But for step one, you say In a Standard Code Module, place this Constant Declaration: Do I do this using the Module object? Thanks so much for your help!
Jun 3 '08 #10
ADezii
8,834 Expert 8TB
OK, I get where to put #2 and think I am set on that. But for step one, you say In a Standard Code Module, place this Constant Declaration: Do I do this using the Module object? Thanks so much for your help!
Yes, create a New Module if you do not have an existing one, then add this Declaration.
Jun 3 '08 #11
fnwtech
48
Yes, create a New Module if you do not have an existing one, then add this Declaration.

Okay, now when I launch the form, I receive an error
Assessment Database can't find the field 'imgPhoto' referred to in your expression.

Is this because my field is named Photo not imgPhoto?
Jun 3 '08 #12
ADezii
8,834 Expert 8TB
Okay, now when I launch the form, I receive an error
Assessment Database can't find the field 'imgPhoto' referred to in your expression.

Is this because my field is named Photo not imgPhoto?
The Name of the Image Control, not a Field, is named imgPhoto (that's why the img Prefix). The Field Name containing the Photo File Name is [Photo] as requested by you.
Jun 3 '08 #13
fnwtech
48
The Name of the Image Control, not a Field, is named imgPhoto (that's why the img Prefix). The Field Name containing the Photo File Name is [Photo] as requested by you.

Okay, got that fixed, I just changed the image control to imgPhoto. Now when I launch, it stops at this line:
Me![photo].SizeMode = acOLESizeStretch

The error is:
Run-time Error 438
Object doesn't support this property or method.

The object is a bound object frame.
Jun 3 '08 #14
ADezii
8,834 Expert 8TB
Okay, got that fixed, I just changed the image control to imgPhoto. Now when I launch, it stops at this line:
Me![photo].SizeMode = acOLESizeStretch

The error is:
Run-time Error 438
Object doesn't support this property or method.

The object is a bound object frame.
It should be:
Expand|Select|Wrap|Line Numbers
  1. Me![imgPhoto].SizeMode = acOLESizeStretch
Jun 3 '08 #15
fnwtech
48
It should be:
Expand|Select|Wrap|Line Numbers
  1. Me![imgPhoto].SizeMode = acOLESizeStretch

Okay, now it stops on this line:
Me![imgPhoto].Picture = CurrentProject.Path & gPHOTO_PATH & Me![photo]
Jun 3 '08 #16
ADezii
8,834 Expert 8TB
Okay, now it stops on this line:
Me![imgPhoto].Picture = CurrentProject.Path & gPHOTO_PATH & Me![photo]
Would you be willing to send me the Database as an E-Mail Attachment?
Jun 3 '08 #17
fnwtech
48
Would you be willing to send me the Database as an E-Mail Attachment?
It is quite a large database, but I can see if I can thin it down by removing some of the data. If you don't mind... that would be great.
Jun 4 '08 #18
ADezii
8,834 Expert 8TB
It is quite a large database, but I can see if I can thin it down by removing some of the data. If you don't mind... that would be great.
I'll send you my E-Mail Address in a Private Message. I'll only need approximately 12 Records with the corresponding Photo Files (*.bmp, *.jpg., etc.). Make sure the actual File Names are the same as those stored in the Database.
Jun 4 '08 #19
ADezii
8,834 Expert 8TB
Because of the nature of the photographic files, I E-Mailed a corrected version of the Database to your E-Mail Address. I'm sure that you understand. Kindly post all other relevant information here at Bytes. Thanks.
Jun 4 '08 #20
fnwtech
48
Because of the nature of the photographic files, I E-Mailed a corrected version of the Database to your E-Mail Address. I'm sure that you understand. Kindly post all other relevant information here at Bytes. Thanks.

Okay, this places the picture file name on the form. Is there a way to have it place the actual photo on the form?
Jun 4 '08 #21
fnwtech
48
Okay, this places the picture file name on the form. Is there a way to have it place the actual photo on the form?

Oops, my mistake. Once I moved the database into the correct folder, it worked.
Jun 4 '08 #22
fnwtech
48
Oops, my mistake. Once I moved the database into the correct folder, it worked.

Okay, I finally have it working. I don't know how my photo field ended up a memo field! Thanks! Now I just need to add this so that the report will also pull the photo in!

Thank you so much. I was really under the gun here!
Jun 4 '08 #23
ADezii
8,834 Expert 8TB
Okay, I finally have it working. I don't know how my photo field ended up a memo field! Thanks! Now I just need to add this so that the report will also pull the photo in!

Thank you so much. I was really under the gun here!
Not a problem, glad it all worked out for you.
Jun 4 '08 #24
fnwtech
48
Thanks for the help on the form, ADezzi,

Now I am trying to get this to work on the report. This is the more critical piece form me, as these need to be printed next week.

Using the code from the form (and I may be way off here):

'Photo Images would be stored in a Photos Directory under the
'Current Project Path

'Not necessary , since I set the Size Mode Property of the Image Control to Stretch
'Me![imgPhoto].SizeMode = acOLESizeStretch

If IsNull(Me![photo]) Then 'No Picture File, display no Picture
Me![imgPhoto].Picture = ""
Else
'Picture File listed, but does the Path and actual File exist?
If Dir(CurrentProject.Path & gPHOTO_PATH & Me![photo], vbNormal) <> ""
Then
'it exists
Me![imgPhoto].Picture = CurrentProject.Path & gPHOTO_PATH & Me![photo]
Else
'display some Error Message to the User, get rid of existing Picture
Me![imgPhoto].Picture = ""
End If
End If

The bolded line is where it is stopping. first, I put this in under the Open Event - not sure if that is where it should be. I did fix the query this report uses, and that is working fine. Any guidance on what is causing this would be greatly appreciated!
Again, thanks
Jun 5 '08 #25
ADezii
8,834 Expert 8TB
Thanks for the help on the form, ADezzi,

Now I am trying to get this to work on the report. This is the more critical piece form me, as these need to be printed next week.

Using the code from the form (and I may be way off here):

'Photo Images would be stored in a Photos Directory under the
'Current Project Path

'Not necessary , since I set the Size Mode Property of the Image Control to Stretch
'Me![imgPhoto].SizeMode = acOLESizeStretch

If IsNull(Me![photo]) Then 'No Picture File, display no Picture
Me![imgPhoto].Picture = ""
Else
'Picture File listed, but does the Path and actual File exist?
If Dir(CurrentProject.Path & gPHOTO_PATH & Me![photo], vbNormal) <> ""
Then
'it exists
Me![imgPhoto].Picture = CurrentProject.Path & gPHOTO_PATH & Me![photo]
Else
'display some Error Message to the User, get rid of existing Picture
Me![imgPhoto].Picture = ""
End If
End If

The bolded line is where it is stopping. first, I put this in under the Open Event - not sure if that is where it should be. I did fix the query this report uses, and that is working fine. Any guidance on what is causing this would be greatly appreciated!
Again, thanks
Assuming everything else is the same, place the provided code into the Format() Event of the Detail Section of the Report.
Jun 5 '08 #26
fnwtech
48
Assuming everything else is the same, place the provided code into the Format() Event of the Detail Section of the Report.
That was it! Perfect.
Thank you so much!
Jun 5 '08 #27
ADezii
8,834 Expert 8TB
That was it! Perfect.
Thank you so much!
You are quite welcome, fnwtech.
Jun 5 '08 #28

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: matt | last post by:
I have this code, works perfectly on Windows server, but now i'm trying to run it on a Linux server, the form submits, i get no errors, but the photo doesnt upload, and the caption file doesnt...
3
by: Ken | last post by:
I have a database called autographs.mdb that is in the "XYZ" folder in the "database" folder. I have a form in the database that I want to display a photo of the celeb on. The photos are in a...
1
by: Bill Strass | last post by:
I have a form showing the records of different people. I would like a photo to be displayed in the form, with each person's record. My digital photo > *.jpg type file and I change each photo...
5
by: bob garbados | last post by:
I am trying to create a database-driven photo gallery for a friend with an admin form to upload images... I can upload a file to the web server, but I want to store the image in a database and I...
13
by: Jose.M.Huerta | last post by:
I'm trying to display in a continuos form some *.jpg. I have a table with the file path, (a photo of a person). Display these photos in a single form is very easy, just using changing some...
4
by: TomA | last post by:
Hi All, I have a picturebox on a form containing the photo of a person. As you advance through the records, the photo updates. Rather than storing the images in an inefficient blob field in a...
7
by: NewDirections | last post by:
I have developed a Access 2000 database to run my business. I use it to track products, Sales, Customers, format Newsletters (select products) for mailing, and etc. What I need to do is add photos...
5
by: NJonge01 | last post by:
Greetings, I've read some great advice on similar topics, just nothing matching exactly what I'm trying I'm pretty close I think on making this work, but note quite there. I want to print a...
1
by: cumupkid | last post by:
II am trying to create a form that will allow me to upload photos to a folder in the site root directory and add the information to the mysql db at the same time. I have created two forms, one...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.