Create Command button to activate hyperlink ?

B

Buford

I am new to Access and cannot use VB quite yet. I am trying to create a
command button in a form that when clicked will open a hperlink pointing to a
document. I have the hyperlink in place and it works if I click on the
hyperlink field itself but want to create a command button to do this.

Can anyone direct me to the commands inside Access to allow me to do this ?
I do not know the "On Click" command to initiate the hyperlink.

Thanks !
 
F

fredg

I am new to Access and cannot use VB quite yet. I am trying to create a
command button in a form that when clicked will open a hperlink pointing to a
document. I have the hyperlink in place and it works if I click on the
hyperlink field itself but want to create a command button to do this.

Can anyone direct me to the commands inside Access to allow me to do this ?
I do not know the "On Click" command to initiate the hyperlink.

Thanks !

Change that field's datatype from Hyperlink to Text.
Store the full path and document name in that field, i.e.
"c:\MyFolder\MyDocument.doc" (without the quotes).

Then code the command button's Click event:
Application.FollowHyperlink [ControlName]

where [ControlName] is the name of the control on the form that
displays the field with the hyperlink address.
 
B

Buford

Thanks Fred....I might not understand the syntax of the command so I might be
missing something obvious but I changed the field to text and created the
command button with the On Click action as Application.FollowHyperlink
[ControlName]

I received the error:
Microsoft Office Access cannot find the Object "Application"

One thing that may effect this is, the document I want to open is a PDF
file.

Can you help resolve the error ?

thanks,

Buford

fredg said:
I am new to Access and cannot use VB quite yet. I am trying to create a
command button in a form that when clicked will open a hperlink pointing to a
document. I have the hyperlink in place and it works if I click on the
hyperlink field itself but want to create a command button to do this.

Can anyone direct me to the commands inside Access to allow me to do this ?
I do not know the "On Click" command to initiate the hyperlink.

Thanks !

Change that field's datatype from Hyperlink to Text.
Store the full path and document name in that field, i.e.
"c:\MyFolder\MyDocument.doc" (without the quotes).

Then code the command button's Click event:
Application.FollowHyperlink [ControlName]

where [ControlName] is the name of the control on the form that
displays the field with the hyperlink address.
 
F

fredg

Thanks Fred....I might not understand the syntax of the command so I might be
missing something obvious but I changed the field to text and created the
command button with the On Click action as Application.FollowHyperlink
[ControlName]

I received the error:
Microsoft Office Access cannot find the Object "Application"

One thing that may effect this is, the document I want to open is a PDF
file.

Can you help resolve the error ?

thanks,

Buford

fredg said:
I am new to Access and cannot use VB quite yet. I am trying to create a
command button in a form that when clicked will open a hperlink pointing to a
document. I have the hyperlink in place and it works if I click on the
hyperlink field itself but want to create a command button to do this.

Can anyone direct me to the commands inside Access to allow me to do this ?
I do not know the "On Click" command to initiate the hyperlink.

Thanks !

Change that field's datatype from Hyperlink to Text.
Store the full path and document name in that field, i.e.
"c:\MyFolder\MyDocument.doc" (without the quotes).

Then code the command button's Click event:
Application.FollowHyperlink [ControlName]

where [ControlName] is the name of the control on the form that
displays the field with the hyperlink address.

I suspect you place the code on the OnClick property line.
That's not how to do this.

Here is how to write code.

Open the Form in Design View.
Select the Command Button.
Display the Command Button's Property sheet.
Click on the Event tab.
On the line that says On Click, write:
[Event Procedure]
Then click on the little button with the 3 dots that appears on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write:

Application.FollowHyperlink [ControlName]

Save the changes.
Change [ControlName] to whatever the actual name of the control is on
your form.
 
B

Buford

You DA MAN !!!

Thanks for the explanation, I was missing that entirely. It worked great
and the instructions were so easy to follow.

I appreciate this very much :)

thanks!

Buford

fredg said:
Thanks Fred....I might not understand the syntax of the command so I might be
missing something obvious but I changed the field to text and created the
command button with the On Click action as Application.FollowHyperlink
[ControlName]

I received the error:
Microsoft Office Access cannot find the Object "Application"

One thing that may effect this is, the document I want to open is a PDF
file.

Can you help resolve the error ?

thanks,

Buford

fredg said:
On Sat, 7 Jun 2008 15:54:00 -0700, Buford wrote:

I am new to Access and cannot use VB quite yet. I am trying to create a
command button in a form that when clicked will open a hperlink pointing to a
document. I have the hyperlink in place and it works if I click on the
hyperlink field itself but want to create a command button to do this.

Can anyone direct me to the commands inside Access to allow me to do this ?
I do not know the "On Click" command to initiate the hyperlink.

Thanks !

Change that field's datatype from Hyperlink to Text.
Store the full path and document name in that field, i.e.
"c:\MyFolder\MyDocument.doc" (without the quotes).

Then code the command button's Click event:
Application.FollowHyperlink [ControlName]

where [ControlName] is the name of the control on the form that
displays the field with the hyperlink address.

I suspect you place the code on the OnClick property line.
That's not how to do this.

Here is how to write code.

Open the Form in Design View.
Select the Command Button.
Display the Command Button's Property sheet.
Click on the Event tab.
On the line that says On Click, write:
[Event Procedure]
Then click on the little button with the 3 dots that appears on that
line.
When the code window opens, the cursor will be flashing between 2
already existing lines of code.
Between those 2 lines, write:

Application.FollowHyperlink [ControlName]

Save the changes.
Change [ControlName] to whatever the actual name of the control is on
your form.
 

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