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!

Search box

Status
Not open for further replies.

Folk

Technical User
Jun 5, 2001
14
US
I was searching for a way to load images into a form and I found the instructions in this address:

"
The problem is that the user must type the full path for each image added. I would like to do something like this:
The user would click on a button and a search box would appear (like the Explorer screen). Then he would click "OK" and the full path would appear into that field.

Thanks

Paulo
 
Hi Folk,

You asking a lot from Access aren't you!!!, I have a little function that searches for the files in a specified directory, if this is any good to you see below, otherwise good luck :)

Make a new blank form.
Make a listbox or a combo-list box and call it 'result'.
Make a text box and call it 'search'.

Now on the properties for the 'search' text box, under 'After Update', paste the following code:


'Start of code
Private Sub search_AfterUpdate()
Path="C:\My Documents\" ' Change this to your directory to search

If IsNull(path) Then path = "\" ' Default to current path if none specified

fsearch = Dir(path & [search])
Filesearch = fsearch

Do While fsearch <> &quot;&quot;
fsearch = Dir
Filesearch = Filesearch & &quot;; &quot; & fsearch
Loop

[result].RowSource = Filesearch
DoCmd.Requery &quot;result&quot;

End Sub
'End of Code


Now you have the code to do a filesearch and put the results in a combo box. so you can select them at your leisure.

Hope some of this helps.

Andrew.
 
Sorry I got &quot;Mouse happy&quot; and hit the submit before I finished.
Forget what I asked.

you need to trim off what you don't want.

One way would be to create a List box and have the full path in one column and the file name in the first column.
make the second columns width 0 and it won't show.
They pick what they want
then in the Afterupdate event of the comobo box you grab the full path from second column and put it where you want.

yourpicture = combobox1.column(1) ' second column

here is a simple function to do that

For a = 1 To Len(filename)
x = InStr(a, filename, &quot;\&quot;)
If x = o Then Exit For
a = x
Debug.Print x
Next
JustPath = Left(filename, a - 1)
JustFile = Right(filename, Len(filename) - Len(JustPath))

DougP, MCP

Visit my WEB site to see how Bar-codes can help you be more productive
 
Oops, sorry man, just noticed this code does'nt Dim the variables, Just add:

Dim Fsearch as string, Filesearch as string, Path as string

To the top of the procedure.


Andrew.
 
Hi Andrew! Hi Doug!

Andrew: I've tried what you told me but, I don't know why, it didn't work... and didn't show me any error message. Do you have any idea of what's happening?

Doug: I've made one blank form and created the list box with two columns. Then I put the function you've written in the AfterUpdate event of the combo box. Finally, I don't know where to put this line:
yourpicture = combobox1.column(1) ' second column

Excuse me, but I'm still a beginner in VB.

Thank you!

Paulo
 
If you email me Folk, I'll send you my form example.

andrew.vanbeck@semefab.co.uk


Andrew.
 
Hi tlbroadbent!

The searchbox worked well. Also, do you know how to make all the path I've choose in the searchbox appear into a field?

Thank you!

[]

Paulo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top