That looks basically all right, although I'd probably do something more
like this:
Dim varURL As Variant
varURL = DLookup("[DocName]", "Query2")
If IsNull(varURL) Then
MsgBox "Sorry, no URL found!", vbOkOnly + vbInformation
Else
Application.FollowHyperlink varURL
End If
Note that you don't need to open the query: DLookup() opens it "behind
the scenes" and extracts the value you specify. If the query returns
more than one record, DLookup() will return the value from the first
record unless you use the third, 'criteria' argument to tell it what to
do.
According to what I have discovered would it be the following?
Dim varX As Variant
varX = DLookup("[DocName]", "Query2")
Application.FollowHyperlink varX
I have put this code in the same event procedure that opens the query. I can
sense this isn't correct. I haven't done anything as complicated as this.
John Nurick said:
If the query returns a single record which contains the path, you can
use DLookup() to get the value from the field in the record, and pass
this to FollowHyperlink.
On Tue, 6 Feb 2007 07:17:00 -0800, scubadiver
Sorry, I don't quite understand. How do I reference "filepath" to a query?
thanks
:
Just use
Application.FollowHyperlink filepath
On Fri, 26 Jan 2007 04:00:00 -0800, scubadiver
Hello,
I hope this is the right section.
I have a form that contains file path and document name info for some
department Q+A word documents. I have a button that opens a query that
isolated the complete file path for a single document selected in the form.
Can I go one step further and use the button to open the document using the
file path?
thanks