Closing Access on Open application

K

Krispy

I have a form that shows a list of hyperlinked documents. They are Word,
Excel, pdf, and some internal reports within the database. When I click on
the hyperlinks, I want the database to close if the hyperlink opens another
program, but stay open if it is an internal report. Is there some code I can
attach to the on-click event, that will do this?

Any help would be greatly appreciated?
 
A

Arvin Meyer [MVP]

Branch your code. If the 4th character from the right is a . (dot) it is an
extension and most likely a program. Like wise if you use the InStr()
function and find a \ (backslash) in the string it is also most likely a
program.
 
K

Krispy

Hi Arvin,
I thought I knew how to branch out the code, but I don't. Could you show me
an example of how you would do this? Would it be an If..Then statement?
 
A

Arvin Meyer [MVP]

OK, how about:

If Instr(1, Me.[Control Name], "\") > 0 Then
Exit Sub
Else
Me.[Control Name].HyperlinkAddress = Me.[Control Name]
End If

BTW, I do not use the Hyperling datatype, preferring instead to use the
hyperlink property of a text field with the path. If you chose to do that,
the second statement would be:

DoCmd.OpenReport "Report Name"
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.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

Top