File Browse

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need users to be able to pick a file from any directory on their hard drive
or on the network.. i basically need a <input type="file"> from HTML, but on
an ms-access form. Can anyone tell me a good class to use for this?

thanks
 
Hi, Ken.
Can anyone tell me a good class to use for this?

You'll find the (Access 97) code here:

http://www.mvps.org/access/modules/mdl0013.htm

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
You'll need to add a reference to Microsoft Office 11 Object library
(Tools>References), but this code should work for you:

Sub GetFile(Control)
Dim retFile As String, dlg As Variant, s As String
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
.InitialFileName = CodeProject.Path
If .Show = -1 Then s = .SelectedItems(1)
End With
If s <> "" Then
retFile = Right(s, Len(s) - InStrRev(s, "\"))
Control.Value = retFile
End If
End Sub
 
Thanks a bunch, this worked great.

Amy Blankenship said:
You'll need to add a reference to Microsoft Office 11 Object library
(Tools>References), but this code should work for you:

Sub GetFile(Control)
Dim retFile As String, dlg As Variant, s As String
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
With dlg
.InitialFileName = CodeProject.Path
If .Show = -1 Then s = .SelectedItems(1)
End With
If s <> "" Then
retFile = Right(s, Len(s) - InStrRev(s, "\"))
Control.Value = retFile
End If
End Sub
 
Hello,

Sorry to have to resurrect this thread, but I have tried both FileDialog and
that great big monstrosity that everyone keeps pointing to ("The Access
Web"), and I can't get either one to work.

I am a newbie with Access VBA, and all I want is a little "Browse" button
that lets the user select a file pathname, beginning with a set folder (i.e.,
C:\this folder\now pick your own subfolder\pick your own file) so they don't
have to type the pathname manually. I don't need to do anything with the file
itself. A website's search engine will look for this pathname and use it as a
destination URL ~ so obviously, typos in the pathnames would be a bad thing.

Can someone please email me directly with a *very simple* step-by-step
procedure for implementing either method? FWIW, I keep running into
"user-defined type not found," yet I have selected the MS Access 11.0 object
library from the References list.

Again, I am a newbie, and I am frustrated. Please go slowly and gently with
me. Thank you. :-)

eddie D0+ mcham A+ uthct D0+ edu
 
You are absolultely right. I was looking at the wrong library. I knew it had
to be something totally bonehead on my part. Thank you!!!!!

I tried it on my home laptop (although it had Office 12.0), and now it
works. I got the Browse button to pull up the FileDialog box, and I just
finished customizing it to both mine and my co-workers' likings.

And then I copied/pasted/emailed the code back to my work Inbox so I can get
this completed first thing manana.

Thanks again! :-)
 
Hello,

I found this thread and the sub routine Amy has posted is perfect. The only
problem is I don't know how to use it. Should I creat a class module and
insert this code? Do I replace 'Control' with the browse button I have
created on my form?

I tried using the class with something like this:

Private Sub btnBrowse_Click()
Dim rnClass As Class1
Set rnClass = New Class1

Me.ReportLocation.Value = rnClass.GetFile

End Sub

So what iIhave is a button on a form which should allow me to browse for a
file, I select a file, which inserts a hyperlink path into a textbox called
ReportLocation.
I know this doesn't work! Can anyone please help? I know this is probably
simple but I can't get it to work as I am new to this.
 
It seems my post went in a strange place.

Hello,

I found this thread and the sub routine Amy has posted is perfect. The only
problem is I don't know how to use it. Should I creat a class module and
insert this code? Do I replace 'Control' with the browse button I have
created on my form?

I tried using the class with something like this:

Private Sub btnBrowse_Click()
Dim rnClass As Class1
Set rnClass = New Class1

Me.ReportLocation.Value = rnClass.GetFile

End Sub

So what I have is a button on a form which should allow me to browse for a
file, I select a file, which inserts a hyperlink path into a textbox called
ReportLocation.
I know this doesn't work! Can anyone please help? I know this is probably
simple but I can't get it to work as I am new to this.
 
Back
Top