WS
asked on
MS Access - Open file or document or website form hyperlink field
Hi,
I have a table that have thousands records and there in one field that have data type "hyperlink" that have link to websites and documents. I want that when hyperlink is click in table it open the website or that document or excel file but it's not happening. Any help?
I have a table that have thousands records and there in one field that have data type "hyperlink" that have link to websites and documents. I want that when hyperlink is click in table it open the website or that document or excel file but it's not happening. Any help?
ASKER
Thank you, this is helpful
I understood this, but can you tell where i should add this function?
Now, a URL is a string like "http://www.example.com/images/somepicture.png". Unfortunately, if you save this as a hyperlink field in a table, it is saved behind the scene as " #http://www.example.com/images/somepicture.png#".
This must be taken care of, if you retrieve the URL directly from a hyperlink field. Luckily, there is a native function of Access to handle this:
CleanUrl = HyperlinkPart(SavedUrl, acAddress)
I understood this, but can you tell where i should add this function?
That you can see in the code right below - to "clean" the address (if needed).
/gustav
/gustav
I don't use the HyperLink data type. Mostly because most of my apps use SQL Server, Oracle, or DB2 as the BE rather than ACE and only ACE supports this specialaized data type.
Just store the path or URL in a text field and use the FollowHyperlink Method to open the document. As long as the extension is one that Windows recognizes, this will work correctly.
Just store the path or URL in a text field and use the FollowHyperlink Method to open the document. As long as the extension is one that Windows recognizes, this will work correctly.
ASKER
PatHartman, that sounds good too , i can go for that but what about picture and excel sheet it will open that too? Also it would be helpful if you have any example using FollowHyperlink Method opening document in table which you can share.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
can you help me why this is not working in this code:
Private Sub Link_Path_Click()
Dim path As String
path = "\\xxx.xx.xx.xx\" & Me.Link_Path
Application.FollowHyperlink Me.path
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@Gustav, this is also not working.
Then your link doesn't work. Insert a debug to view what you try to open:
Private Sub Link_Path_Click()
Dim path As String
path = "\\xxx.xx.xx.xx\" & Me.Link_Path
Debug.Print path
Application.FollowHyperlink path
End Sub
/gustav
ASKER
how to insert debug when code is not giving any error and not displaying anything either?
Also note one thing the field link_path data type in hyperlink , does that create any problem?
Also note one thing the field link_path data type in hyperlink , does that create any problem?
It is inserted in my code above.
Press Ctrl+G and study the output.
/gustav
Press Ctrl+G and study the output.
/gustav
ASKER
it's just taking the me.Link_path, it's not concatenating the "\\xxx.xx.xx.xx\" path.why is this so?
That is not possible, so look carefully again - and/or copy/paste your code here.
/gustav
/gustav
ASKER
i found a problem while breaking it and i think this is the problem : path= "\\xxx.xx.xx.xx\#GLO\ALL\t est.pdf# , so these "#" are not letting it opening this but i haven't add these "#" , from where these "#" signs are coming??
Yes, you've asked about that above, but here it is again:
' Strip leading and trailing octothorpes from URL string.
Address = HyperlinkPart(Url, acAddress)
' If Address is a zero-length string, Url was not wrapped in octothorpes.
If Address = "" Then
' Use Url as is.
Address = Url
End If
/gustav
ASKER
where i should add this code , in the on click event between code or where?
Also what if i use datatype as text instead of hyperlink, will that work?
i use datatype text it gives run time error 490 (Cannot open the specififed file) although the file is at the specified location.
Also what if i use datatype as text instead of hyperlink, will that work?
i use datatype text it gives run time error 490 (Cannot open the specififed file) although the file is at the specified location.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
it says cannot open the specified path and in the immediate window it display this "\\xxx.xx.xx.xx#\GLO\ALL\t est4.xlsx# ". still # are there.
Can't tell. If I run similar code, I get:
s = "#\GLO\ALL\test4.xlsx#"
? Application.HyperlinkPart(s, acAddress)
\GLO\ALL\test4.xlsx
/gustav
ASKER
Thank you Gustav, the code above started working when i change hyperlink field to text.
Thank you again.
Thank you again.
Show pictures directly from URLs in Access forms and reports
It's about downloading pictures, but you'll see that the URLs are working.
/gustav