hyperlink

P

Pietro

Hi all,
I want to assign a button ,that once clicked it opens a window,so that i
may select a certain file ,then the path of this file is saved in a
textbox,so once i click on this textbox i may open this file (it works as a
hyperlink).
Does it make sense?
 
D

Dale Fye

Pietro

use the windows File Open/Save Dialog API to get the filename and store it
in a textbox. You can get the code at:
http://www.mvps.org/access/api/api0001.htm

use the docmd.followhyperlink method in the DoubleClick event of the textbox
or in the OnClick event of a command button to actually open the file.

HTH
Dale
 
K

Ken Sheridan

Download and expand the Zip file of Bill Wilson's BrowseForFileClass class
module from:

http://community.netscape.com/n/pfx...yMessages&tsn=1&tid=22415&webtag=ws-msdevapps

and add the module to your database. On your from add a text box named
txtPath, and a 'Browse' button with the following code in its Click event
procedure:

On Error GoTo Err_Handler

Dim OpenDlg As New BrowseForFileClass
Dim strPath As String
Dim strAdditionalTypes As String
Dim strFileList As String

strFileList = "*.bmp; *.jpg"
strAdditionalTypes = "Image Files (" & strFileList & ") |" & strFileList

OpenDlg.DialogTitle = "Select File"
OpenDlg.AdditionalTypes = strAdditionalTypes
strPath = OpenDlg.GetFileSpec
Set OpenDlg = Nothing

Me.txtPath = strPath

Exit_here:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_here

In the above example I've set the AdditionalTypes property of the class to
image files (.bmp and .jpg) to show how you can add particular file types to
the list of types included by default in the dialogue. These will appear
first in the list when the dialogue opens. Alternatively you could
permanently amend the string assigned to the strFilter variable in the
module's Class_Initialize procedure to include other file types in the list
whenever an instance of the class is established.

In the Click event procedure of the txtPath control put:

On Error GoTo Err_Handler

FollowHyperlink Me.txtPath

Exit_here:
Exit Sub

Err_Handler:
MsgBox Err.Description, vbExclamation, "Error"
Resume Exit_here

to open the selected file when the text box is clicked

Ken Sheridan
Stafford, England
 

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