Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is it possible to select a file to put into db

Status
Not open for further replies.

Schaap

Technical User
Jul 6, 2004
54
NL
Is it possible to select a file (photo,doc, power point slide etc) with access 2000.

What I wanna do :

I have an fill in form for my database.
I got 3 directories on HDD : Photo, PPSlide and Offer.

I wanna know if it is possible (and how) to have a fill in field that is linked to one of the directories above. So I can choose (all the photo's visible in MsgBox) the right photo (by clicking), and link (put) it into the database.(In the Photo directorie I have put a lot of photo's).

Is this possible I couldn't found anything what looks like this, please let me know !
 
Hi
You could define a table with one or more columns of type "hyperlink", and put the path of the photo whatever in the column, clicking on it will open the photoapplication and show the photo

see help on hyperlink to see how

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Hi again,

what KenReay says is not what I want/meant (if I understand it right).
What he says is :
put a hyperlink in a table and when you click on it you see the linked file.

what I want is :
the user put a photo in a directory Photo (somewhere on HDD for example).
On the fill in form the user selects a field (where the photo has to be linked to). I want that the user will see some kind of inputbox. In the inputbox the user sees all the photos that are in the directory photo. And then the user can select his/her own photo. Then the (hyper-)link of this photo will be saved into the database.

So my question again is if this is possible in access 2000 and how will I do that. If the solution of KenReay is the right one, please explane me more cause I don't see it myself how the user can select his/her photo out of all the photos in the particular directory.
 
of course it's possible. you need to write some code. what KenReay has explained is the result of what you'll have after doing what you want.

some of the things you need to do to get to that point:
- you need to put a listbox on your form

- you need to write code using the Dir command to navigate the directories/files on your system as the user double clicks on a directory in the listbox (alternatively, if you can add the VB Dir/File list controls into Access, that will take care of most of this logic for you).

- you need one or more picturebox/image controls (control array) to display your photos when you get to a directory that has photos in them

- a command button to "Save" the path to the photo in your database table. there are many ways to do this, you can highlight the photo file in the list box (or multiple select) or next to each picture box put a checkbox that the user can select to indicate he wants to save it, and then when he clicks the Save button, it would store the path/file to all those selected.

 
I got a listbox ! (see also my first thread)
But in other discussions I read that a combobox on a subform will be better when the list is getting longer !?!

But I don't know how it is possible that the user can select a filename of a photo on HDD with the dir command.
The dir command returns only 1 filename !!! So it's not possible to select 1 photo out of a list.

I tried also with filesearch (out of help function)
with code like : set fs = Application.Filesearch
With fs
.Lookin = P:\My Documents\Database Photo
.Filename = "*.jpeg"
If .Execute > 0 then
MsgBox (&.Foundfiles.Count)
For i = 1 to .foundfiles.Count
MsgBox (.FoundFiles(i))
Next i
Else
MsgBox ("No files found")
End If
End With

Please let me know/see how this can be done !
 
if you want multi-selection then you have no choice, you either use the listbox(combobox will not work), or come up with a different paradigm for making the selection - for instance, maybe, like other programs, you display all the images as thumbnails, put a checkbox under each called "select" and then when the user clicks the save button, the paths of the selected ones are saved.

The Dir command returns the same set of files you get with your .Filesearch - you just need to use it properly.

s = Dir$("P:\My Documents\Database Photo\*.jpeg"
while (s <> "")
Listbox.AddItem s
s = Dir$
wend
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top