hyperlink and command buttons

G

Guest

On start up, a form pops up that lets the user search projects that the
company has done. The user can not modify data on the search form but then
can press the "add project" or "edit project" button and another form will
pop up allowing them to add/delete or edit as they need too. All three forms
are linked to the same table which has a field for a hyperlink. When the user
clicks on the "add project" or "edit project" buttons I would like them to be
able to insert a hyperlink in a text box that is bound to the hyperlink field
on the table (this, I can accomplish). My question is, can I have a command
button on the search form that does not show the actual hyperlink but when
the user clicks on it it follows the hyperlink?

I know that I can add a hyperlink to a command button. I can't figure out
how to connect a command button to a field on a table due to the fact that
every record's hyperlink will be different.

Thank you
Katie
 
D

Dirk Goldgar

Katie said:
On start up, a form pops up that lets the user search projects that
the company has done. The user can not modify data on the search form
but then can press the "add project" or "edit project" button and
another form will pop up allowing them to add/delete or edit as they
need too. All three forms are linked to the same table which has a
field for a hyperlink. When the user clicks on the "add project" or
"edit project" buttons I would like them to be able to insert a
hyperlink in a text box that is bound to the hyperlink field on the
table (this, I can accomplish). My question is, can I have a command
button on the search form that does not show the actual hyperlink but
when the user clicks on it it follows the hyperlink?

I know that I can add a hyperlink to a command button. I can't figure
out how to connect a command button to a field on a table due to the
fact that every record's hyperlink will be different.

The command button can follow the hyperlink stored in the field of the
current record, by executing a line of code like this:

Application.FollowHyperlink Me.MyHyperLinkField
 
G

Guest

I guess it's a compliment but you assumed that I would know what you were
telling me to do but I don't. Where do I put that code and what do I need to
change? I tried doing an 'On Click' event for the command button and changed
the 'MyHyperLinkField' to the field that I want it to open but I get an error
that says "invalid use of Null" and when I debug it tells me "Ambigious
selection". Please help

Thank you
Katie
 
D

Dirk Goldgar

Katie said:
I guess it's a compliment but you assumed that I would know what you
were telling me to do but I don't. Where do I put that code and what
do I need to change? I tried doing an 'On Click' event for the
command button and changed the 'MyHyperLinkField' to the field that I
want it to open but I get an error that says "invalid use of Null"
and when I debug it tells me "Ambigious selection". Please help

Did you create an event procedure for the button, so that the "On Click"
line of the button's property sheet says "[Event Procedure]" and you
have created a procedure in the form's module that looks like

Private Sub <YourButtonName>_Click()

Application.FollowHyperlink Me.<YourHyperLinkField>

End Sub

?

Please post the actual code of the Click event procedure, as you have it
now, including the "Private Sub ..." and "End Sub" statements.
 
G

Guest

Here's the code:

Private Sub Capsule_Click()
Application.FollowHyperlink Me.[Project Capsule]
End Sub

The name of the command button is 'Capsule' and the name of the hyperlink
field is 'Project Capsule'. Thanks

Katie

Dirk Goldgar said:
Katie said:
I guess it's a compliment but you assumed that I would know what you
were telling me to do but I don't. Where do I put that code and what
do I need to change? I tried doing an 'On Click' event for the
command button and changed the 'MyHyperLinkField' to the field that I
want it to open but I get an error that says "invalid use of Null"
and when I debug it tells me "Ambigious selection". Please help

Did you create an event procedure for the button, so that the "On Click"
line of the button's property sheet says "[Event Procedure]" and you
have created a procedure in the form's module that looks like

Private Sub <YourButtonName>_Click()

Application.FollowHyperlink Me.<YourHyperLinkField>

End Sub

?

Please post the actual code of the Click event procedure, as you have it
now, including the "Private Sub ..." and "End Sub" statements.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Katie said:
Here's the code:

Private Sub Capsule_Click()
Application.FollowHyperlink Me.[Project Capsule]
End Sub

The name of the command button is 'Capsule' and the name of the
hyperlink field is 'Project Capsule'. Thanks

Hmm, it may be necessary to extract the address from the hyperlink. I
usually use plain text fields to store URLs, so that hasn't come up for
me before. Try this:

'----- start of revised code -----
Private Sub Capsule_Click()

Application.FollowHyperlink _
Me.[Project Capsule].Hyperlink.Address

End Sub
'----- end of revised code -----

If that doesn't work, please report the exact error message (and error
number, if it gives you one) that you get.
 
G

Guest

Method or data member not found (Error 461)

In my "add project" and "edit project" forms, the user pastes or types a
hyperlink address into a text box but due to many addresses being long and
messy, on the search form i want the user to be able to clearly find a clean,
neat button labeled "Project Capsule" that will take them to the project
capsule for that record. hope that explains a little more of why i'm doing to
do something to silly.

Thank you
Katie


Dirk Goldgar said:
Katie said:
Here's the code:

Private Sub Capsule_Click()
Application.FollowHyperlink Me.[Project Capsule]
End Sub

The name of the command button is 'Capsule' and the name of the
hyperlink field is 'Project Capsule'. Thanks

Hmm, it may be necessary to extract the address from the hyperlink. I
usually use plain text fields to store URLs, so that hasn't come up for
me before. Try this:

'----- start of revised code -----
Private Sub Capsule_Click()

Application.FollowHyperlink _
Me.[Project Capsule].Hyperlink.Address

End Sub
'----- end of revised code -----

If that doesn't work, please report the exact error message (and error
number, if it gives you one) that you get.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
D

Dirk Goldgar

Katie said:
Method or data member not found (Error 461)

In my "add project" and "edit project" forms, the user pastes or
types a hyperlink address into a text box but due to many addresses
being long and messy, on the search form i want the user to be able
to clearly find a clean, neat button labeled "Project Capsule" that
will take them to the project capsule for that record. hope that
explains a little more of why i'm doing to do something to silly.

It's not clear to me now whether your "hyperlink" field, which you have
told me is named "Project Capsule", really is a Hyperlink data type.
I'm wondering if maybe it's a text field instead. But even before that,
I'd like to verify what the name of the field really is, because the
error message you're getting suggests that there is no field or control
on your form named "Project Capsule".

Please open the form in design view, select the text box that is
displaying this hyperlink field, open its property sheet, and report two
of its properties: Name (on the Other tab of the property sheet) and
Control Source (on the Data tab of the property sheet). Something here
isn't set up the way I thought from your description, and I need to find
out what it is.
 

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