Button to Search Windows Explorer

K

Kedd123

I have a field that contains the path to a picture and an image control that
displays the picture on a form. Is it possible to create a button to browse
windows explorer and allow a user to select the picture and paste the
picture's path name into the text field?

I am looking for a way around typing a long path name and file name each
time a link to a picture needs to be added to a record in the database.

Thanks for the help!
 
J

Jack Leach

No problem... what you need is some common dialog APIs. See this:

http://www.mvps.org/access/api/api0001.htm

copy & paste into a new standard (not a form) module and call the dialog
like so:

Me.TextBoxControl = GetOpenFile("C:\", "Please Select File")

This will open the File Open dialog and passed the selected file to your
control (or a string variable if you prefer). If you go through the list of
APIs (and everything else) at MVPS you'll see some for selecting folders,
starting applications, etc. Very handy stuff here.

hth


--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
J

Jack Leach

FYI, a common way to handle pictures for records in forms is to use an
unbound picture control with the path stored in the record. Then on the
form's Current event set the image control's Picture property to the path
stored in the table.

Private Sub Form_Current
Me.PicControl.Picture = Me![PicturePathField]
End Sub

People sometimes decide to use an OLE field to store the picture, which is a
complete waste of resources in almost all cases. This way you store only the
path, not the picture itself. Just make sure the pics are in a controlled
folder and the paths aren't going to change.

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 

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