Using MS Access/size compare to picture

Advertisement


Question
YESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
your the best when i added ".jpg" it worked perfectly
you realy helpt me out here
it just reased one more question
my data base now is in folder "A" in this folder there is a sub folder"B"
when i enter the path's to the pictures
i enter E:\database\screen shots\rc1\pdvd000.jpg
only when i will move my data base folder to another drive in te future
i will have to reenter al my paths
is there a way to enter the paths so that the starting point of the search for the pictures will always be folder "A"???
im not sure if this is posible in access
i know when yo make a web page on yoyr hard drive you can move it form drive to drive as long as the complete projects stays in the same folder
(i ask this now before i start writhing al my paths)
if its not posiible then its not a big problem but if it is it makes thing more easy for the future

yhanks again this will be the last time :))

-------------------------
Followup To
Question -
Hi there again
I just can't get it to work
but i think i came very close this time
I drag the picture icon in the field named it  pic1, drag the field on my screen which contains the document name (i renamed the field in my table to shot1 so that there are no spaces)
Richt clickt in my form went to built event , went to program code
In the top left i selected form in the top right i selected current
Then i tried several things all with out success i will give you three examples
(the error messages on my computer are in Dutch, because I'm Dutch so I will try to translate them as good as possible)

Ex 1

I enter this: me.imgpic1.picture=me!textshot1

The following error came up in form view
Compile error
cant find method or data part
the ".imgpic1" part was higlighted bleu


Ex 2

Me.pic1.picture=me!textshot1

Error 2465 cant find field textshot which is mentioned in the expression


Ex 3 this one came the closest i think

Me.pic1.picture=me!textshot1

Error 2220 cant open file
E:\data\screen\screen shots\rc1\pdvd000 (this is what i typ't in the field)
This part:” E:\data\screen\screen shots\rc1” i copied from properties and then just enterd the file name

I tried putting the text in the field between this marks : “   ”  that did not help
and i tried making the text a hyperlink in the design view of the table as wel as in the properties on the text box on the form

Nothing helpt

i realy hope this would work or will work in the future becouse i have 6GB of pictures to make a data base off

thanks again i know im trouble


-------------------------
Followup To
Question -
sorry to stalk you again but as i said before im a rookie at this
and i still didi not get it to work
i did this
enterd an unbound object choose a random picture (in propertys i namend the box PIC 1)

then i placed the text box with has the name of the docu ment in it on the form (in my main table this field is called "screen shot 1" so this is then the name of the text box)

then i richt click any wher on the form and go to "build event" / "expression builder"
and enter this text : me.imgpic1.picture=me!textscreen shoot 1

but then i get al sorts of syntax errors
what do i do wrong ???
thanks again and again
-------------------------
Followup To
Question -
hi there again thanks for the answer only the answer gave a few new questions

(btw im a learning quite fast but still a beginner at access)
when i want to ad an unbound object the wizzrd automaricly starts ... wat do i do and what do i select ... canceling ends up in deleting the object

then in this line "Me.imgPicture1.Picture = Me!txtPicture1" im i correct when i think "picture1" is the field name?? and is this a "evnt build up" or a programm code

then you state "Generally this is done in the On Current event of your form" where is this on cuurent event
i looked in properties but ther i found before update and stuff like that

thnaks in advance AGAIN



-------------------------
Followup To
Question -
hi there just a small question
i use access 2003 (reinstalled photo editor sa that i can use jpg  in access)
in my data base i use about 3 pictures per record
now if linkend them instead of imbead them
my data base got quit big
(there are 345 records)
the pictures are all the same size (400kb)
is it normal that the data base grows more the the size of the picture even if you just link them ????

for example my data base is 1,2GB with pictures
and 119 with out pictures
but the total of pictures combined are roughley 360 mb (i already used repair and compact)
so the question is is this normal ???
thanks in advance

Answer -
Yes it is normal, that's why its not recommend to use an OLE field to display pictures. What I do when I want to display a picture associated with a record is to store the path and filename of the image file in the record. I then use an UNBOUND image control and set the Picture property of that control to the image file. Generally this is done in the On Current event of your form. Something like this:

Me.imgPicture1.Picture = Me!txtPicture1

HTH
Scott<>
Answer -
When you drag an Image control onto a form it prompts you to select a Picture file. You can select any picture file, doesn't matter.

The imgPicture1 is the name of the Image control. The txtPicture1 is the name of a text control bound to the field that stores the path and file to the picture.

The On Current is an Event for the form, not a specific control. You have to click in the area ourside the grid but within the form window to select the form.

And yes, you want to use Code Builder or expression to enter the code.

HTH
Scott<>
Answer -
First you might want to look at this site:
http://www.xoc.net/standards/rvbanc.asp

It has info about naming conventions to use in building Access apps.

Second, you should not use spaces in object names. That's what's causing your problems.

The line should be:
me.imgpic1.picture=me!textscreenshoot1

This means changing the name of the control. Also, you said you named the control PIC 1, but you are referring to imgpic1. If you do put spaces in object names you need to bracket them so that:

me.imgpic1.picture=me![textscreen shoot 1]

would also be correct.

If you do get an error message, you should let me know the message. Sometimes the problem may not be as obvious and knowing the message may help me diagnose the problem.

HTH
Scott<>
Answer -
The problem here is you are not using the correct names. In the Other tab of the Properties list for any control is its name. That's what you have to use to refer to the control in code. The initial error messages you were getting are due to the wrong names.

The last message about not opening the file looks like the code worked, but the problem is your filename. You aren't typing the file extension (or it doesn't have an extension). You need to use the extension so Windows knows what file type it is.

Scott<>


Answer
There are a few ways to deal with this. One way would be to create a parameters table. this would be a one record table that would store info used in processing. You would then store the base path there.

But the way I would do it is to use the function found here:
http://www.mvps.org/access/general/gen0007.htm
to return the folder where the database is currently stored. And then only store the relative location and concatenate. For example you would store just:
\B\imagefile.jpg
and use
Me!imgPic1.Picture = CurrentDBDir() & Me!txtShot1

HTH
Scott<>

Using MS Access

All Answers


Answers by Expert:


Ask Experts

Volunteer


Scottgem

Expertise

I can answer almost all types of questions relating to Microsoft Access usage and application design. My strengths are database and interface design.

Experience

I've been designing databases for over 15 years working with dBase, FoxPro, Approach and Access.

Organizations
Author of Microsoft Office Access 2007 VBA
Techncial Editor for Special Edition Using Microsoft Access 2007 and Access 2007 Forms, Reports & Queries From Que Publishing

©2012 About.com, a part of The New York Times Company. All rights reserved.