file browse

G

Guest

I have seen a bunch of references to the
http://www.mvps.org/access/api/api0001.htm link, but I am unsure how to use
it. I added it as a module and then added this code to my form:

Private Sub cmdBrowse_Click()

Me.txtMouFile = TestIt()

End Sub

The issue I have is I don't know how to imput the file chosen into the
form's text box. I need it to display as an icon.

Thank you for your assistance!
 
D

Douglas J Steele

The TestIt function wasn't designed to return the selected file name.

If you want to change it to do that, use

Function TestIt() As String
Dim strFilter As String
Dim lngFlags As Long
strFilter = ahtAddFilterItem(strFilter, "Access Files (*.mda, *.mdb)", _
"*.MDA;*.MDB")
strFilter = ahtAddFilterItem(strFilter, "dBASE Files (*.dbf)", "*.DBF")
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.TXT")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
TestIt = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Hello! Open Me!")
End Function
 
G

Guest

First, Testit does not return any value. That is why you are seeing nothing
in your text box.
The GetOpenFile function is closer to what you want, but only allows you to
see mdb files. You will probably want to use the GetOpenFile as a template,
and make your own changes to use it like you want it.

Now, as to displaying as an icon. What is it you are trying to do? This
code does not start a program or open a file, or do anything other than
return a full path and filename as a string unless the User clicks cancel or
hits escape, then it returns an empty string. This can be very useful for
such tasks as inmporting or exporting data, pointing to a location to link to
a back end, or any other task where you need to allow the user to find a
file. What you do with that string is up to you.
 
G

Guest

Basically, what I am trying to do within the form is to add a file (.doc,
..xls, or .pdf) to a field within the form. I can do this the hard way (right
click on the control, click insert object,click "create from file"...), but
my users will find that method too difficult; therefore, will not use it. I
am trying to find a way for the user to click a "Browse" button, find the
file on their hard drive, and insert it into the field.

Thank you in advance for your assistance.
 

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