hyperlink command button

G

Guest

hi...

i've posted a few times regarding my issue.... but i haven't had much luck
in solving it. I have created a database with a form that will allow users
to select a file from a folder on the computer and attach it to each record.
The user presses the command button, a file dialog box opens, they choose a
file and that file path populates a text box on the form. The data type
inside the text box is set to be a hyperlink. My goal is to have a hyperlink
to a file attached to each record, such that when the user clicks on the
hyperlink, the file will open. Unfortunately, the files will not open when
added to the database this way. NOW - instead of using my 'created' command
button and I use the hyperlink button on the menu bar, i am able to create a
working hyperlink (one that opens when clicked). Is it possible to create
the same effect on my form (possibly via my existing command button) rather
than making the user use the existing hyperlink menu button?

Thanks,
Erin
 
J

Jayyde

I would think you'd want to make that data type a string, change the text
box's IsHyperlink property to Yes, then in your command button set the text
box's .Hyperlink.Address = StringFilePath that you are storing.

hth
-Jayyde
 
G

Guest

I tried that. Actually... the data type is set to hyperlink in the table
design view. I tried to set the .Hyperlink.Address = StringFilePath and
it's not working either. Any other ideas????
 
J

Jayyde

Just out of curiosity, on the form, is the text box set to IsHyperlink =
Yes?
No idea if that'd help at all, but anything's worth a shot

-Jayyde
 
G

Guest

I'm curious....I put a hyperlink on my form as a command button and I also
tried putting on as a label on the form.....when I envoke it it's supposed to
open up a PDF file on my c drive....but I get an Access warning message about
hyperlinks can be harmful to your computer.....

Any idea how I can surpress this message. I thought maybe you got it too?
 
G

Guest

If you get an answer doing that would you let me know...I've been searching
for days on how to surpress it.
 
G

Guest

If you're interested I found this code on the net and it surpressed the
warning message for me.

Create a module and paste this code into it.

Public Const WIN_MIN = 2 'Open Minimized

'***Error Codes***
Private Const ERROR_SUCCESS = 32&
Private Const ERROR_NO_ASSOC = 31&
Private Const ERROR_OUT_OF_MEM = 0&
Private Const ERROR_FILE_NOT_FOUND = 2&
Private Const ERROR_PATH_NOT_FOUND = 3&
Private Const ERROR_BAD_FORMAT = 11&

'***************Usage Examples***********************
'Open a folder: ?fHandleFile("C:\TEMP\",WIN_NORMAL)
'Call Email app: ?fHandleFile("mailto:[email protected]",WIN_NORMAL)
'Open URL: ?fHandleFile("http://home.att.net/~dashish", WIN_NORMAL)
'Handle Unknown extensions (call Open With Dialog):
' ?fHandleFile("C:\TEMP\TestThis",Win_Normal)
'Start Access instance:
' ?fHandleFile("I:\mdbs\CodeNStuff.mdb", Win_NORMAL)
'****************************************************

Function fHandleFile(stFile As String, lShowHow As Long)
Dim lRet As Long, varTaskID As Variant
Dim stRet As String
'First try ShellExecute
lRet = apiShellExecute(hWndAccessApp, vbNullString, _
stFile, vbNullString, vbNullString, lShowHow)

If lRet > ERROR_SUCCESS Then
stRet = vbNullString
lRet = -1
Else
Select Case lRet
Case ERROR_NO_ASSOC:
'Try the OpenWith dialog
varTaskID = Shell("rundll32.exe shell32.dll,OpenAs_RunDLL " _
& stFile, WIN_NORMAL)
lRet = (varTaskID <> 0)
Case ERROR_OUT_OF_MEM:
stRet = "Error: Out of Memory/Resources. Couldn't Execute!"
Case ERROR_FILE_NOT_FOUND:
stRet = "Error: File not found. Couldn't Execute!"
Case ERROR_PATH_NOT_FOUND:
stRet = "Error: Path not found. Couldn't Execute!"
Case ERROR_BAD_FORMAT:
stRet = "Error: Bad File Format. Couldn't Execute!"
Case Else:
End Select
End If
fHandleFile = lRet & _
IIf(stRet = "", vbNullString, ", " & stRet)
End Function
'************ Code End **********




then you have to pass your pdf file name with the path to it like so.

Call fHandleFile("C:\...",Win_Normal)

It works like a charm for me. Hope this helps.
 

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