Storing pictures externally of DB

G

Guest

I have a lot of pictures. All pictures are stored in a subdirectory of the DB backend. Currently I have to manuall
enter in the field the location and name of the file. What I would like to do, in my table I have a field calle
fldCompanyNo, all the pictures are numbered after the company number, i.e. CompanyNo = 1234, the picture i
1234.jpg. How can I program it to do this and if no picture is avaliable, show picture nopicture.jp

Thank you
 
P

Phil Jones

You can use the file open dialog to prompt the user for the filename. Once
you have that, you can copy the file anywhere and rename it if you wish,
storing the filename in your database. Then you can use this field as a
recordsource for an image control to display the picture.

If IsNull(ImageFileName) then
Image1.Image= "C:\MyPics\PicNotAvailiable.jpg"
Else
Image1.Image= ImageFileName
End if

RK said:
I have a lot of pictures. All pictures are stored in a subdirectory of the
DB backend. Currently I have to manually
enter in the field the location and name of the file. What I would like to
do, in my table I have a field called
fldCompanyNo, all the pictures are numbered after the company number, i.e.
CompanyNo = 1234, the picture is
 
T

Ted Allen

What I would do is place some code in the form's On
Current event to check the directory to see if a picture
matching ID.jpg exists, and if so set it as the picture
source for an image object on the form.

An example would be (air code):

Dim strFilePath as String
Dim strFileName as String
Dim strFileFound as String

strFilePath = "\\ServerName\etc\"
strFileName = Me.ID & ".jpg"
strFileFound = Dir (strFilePath & strFileName)

If strFileFound = strFileName Then
Me.MyPicObject.Picture = strFilePath & strFileName
Else
Me.MyPicObject.Picture = strFilePath & "nopicture.jpg"
EndIf

Of course you will need to substitute your actual names
for your ID and picture objects, and also enter your
actual path.

Also, when you first place the image object on your form
it will ask you to identify an image file as the source.
Just pick any file, your code will modify the source at
run time.

Hope that helps.

-Ted Allen
-----Original Message-----
I have a lot of pictures. All pictures are stored in a
subdirectory of the DB backend. Currently I have to
manually
enter in the field the location and name of the file.
What I would like to do, in my table I have a field called
fldCompanyNo, all the pictures are numbered after the
company number, i.e. CompanyNo = 1234, the picture is
1234.jpg. How can I program it to do this and if no
picture is avaliable, show picture nopicture.jpg
 
R

RK

There has to be a better way to do this, there are a lot
of pictures.

Thank you for your input RK
 
T

Ted Allen

Take a look at the code I posted earlier, it should fully
automate the process (other than initially saving and
naming the file, but you didn't ask about that so I
assume you already have them or have a satisfactory
process for it).

-Ted Allen
 
M

Marek

Whatever you do don't use a DB for the purpose of tracking
images. Use something like FotoWare's FotoStation -
that's what the pro's use and it's cheap. It uses
metadata - JPEG image files already have, effectively,
database fields that you can enter information into - and
search for it afterwards.
 

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