Using query info to open word document

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

Guest

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
 
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

If you format it as a hyperlink, Word should open it.
 
Just use
Application.FollowHyperlink filepath

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
 
The file path is in the query and the field is the following:

File: [type] & [prefix] & "-" & [DocName]

This gives the complete filepath. Can I format it has a hyperlink in the
query?

thanks.
 
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.
 
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.
 
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.
 
Hello, thanks for the reply.

It seems to be working fine now.

Thanks



John Nurick said:
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
 

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