Using a browse button

G

Guest

I have attempted to use the code supplied on
http://www.mvps.org/access/api/api0001.htm and as I have limited knowledge of
VBA have found it a bit confusing. The Issue I have however, is that how do I
link this code to a button, I have completed usual practice of using the 'on
click' event in the properties but this requires the use of a sub rather than
a function. Please advise.

Thanks
 
G

Guest

Copy the code in the light blue box into a new module and save it with
whatever name you like.

In the "on click" event insert the following:


On Error GoTo Err_txtDocs_DblClick
Dim strFilter As String
Dim lngFlags As Long
Dim DocPath As String

strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
'MsgBox "You selected: " &
DocPath = ahtCommonFileOpenSave(InitialDir:="C:\", _
Filter:=strFilter, FilterIndex:=3, Flags:=lngFlags, _
DialogTitle:="Select Document")

If Not DocPath = "" Then
Me.AttDoc = DocPath
End If
Exit_txtDocs_DblClick:
Exit Sub

Err_txtDocs_DblClick:
MsgBox Err.Description
Resume Exit_txtDocs_DblClick


Create a text box called "AttDoc" (mine is bound) and whatever file you
choose will go into the field.

It does for me anyway.
 
D

Douglas J. Steele

What you do is copy everything between Code Start and Code End into a new
module (make sure it's not a class module nor the module associated with a
form. Also make sure when you save it that the name of the module isn't the
same as any of the functions or subs within the module)

Now, in the Click event of your button, put code similar to the 4 lines of
code at the top of the page.
 

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