Need help with file dialog box

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

Guest

I'm working on a pretty simple database and i'm trying to attach a hyperlink
to a file for each record. Basically, the user enters data and attaches a
link to the associated file with the data. The original files are stored in
a folder on the computer hard drive.

I used the below guidance to create the file dialog box, however, I am
unable to get the file path (which I would like to hyperlink) to save with
each record. Does anyone out there have any suggestions on how i can do
this?

http://support.microsoft.com/kb/824272/
 
this returns the fully qualified filename including the path

this code works with the API functions written by Ken Getz
that can be downloaded here:

code - OpenFile - KenGetz
http://www.mvps.org/access/api/api0001.htm

'-------------------------------------- BrowseFile
Function BrowseFile(pTitle As String, Optional pFilter As
String, Optional pInitialDir As String) As String
'crystal
'strive4peace2006 at yahoo.com

'CALLS -->
'ahtCommonFileOpenSave

'PARAMETERS
'pTitle --> title of OpenFile dialog box
'pFilter --> ie:
' "Excel Files (*.xls)" & vbNullChar & "*.xls" & vbNullChar
'if no filter is specified --> all files
'pInitialDir --> "c:\data"
'if no directory specified -- database directory

On Error GoTo BrowseFile_error

Dim mFilename As String

mFilename = Nz(ahtCommonFileOpenSave( _
Flags:=ahtOFN_FILEMUSTEXIST Or ahtOFN_HIDEREADONLY Or
ahtOFN_NOCHANGEDIR, _
InitialDir:=IIf(Len(Nz(pInitialDir)) = 0,
CurrentProject.Path, pInitialDir), _
Filter:=pFilter, _
DialogTitle:=pTitle, _
OpenFile:=True))

If Len(mFilename) = 0 Then Exit Function

On Error Resume Next

BrowseFile = mFilename

BrowseFile_exit:
Exit Function

BrowseFile_error:
msgbox Err.Description, , "ERROR " & Err.Number & "
BrowseFile"
Stop
Resume
Resume BrowseFile_exit

End Function
'------------------------------

Have an awesome day

Warm Regards,
Crystal

MVP Microsoft Access
strive4peace2006 at yahoo.com
 

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

Back
Top