Hyperlink Command Button

G

Guest

I want to add the Insert hyperlink function to a command button on a form, at
present I have a field on a form that requires a different hyperlink for each
record so the user, click ito the field then selects the insert hyperlink
button on the tooldbar, but i want to remove this toolbar and have a command
button the form itself to simply open the insert hyperlink dialgouse box, I
have tried a macro and run command, but its doesn't seem to work, it seems
really simple but cant get it working, any ideas, many thanks
 
A

Allen Browne

If you use a command button, it has focus when clicked, and Access cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

in message
news:[email protected]...
 
G

Guest

thanks Allen, worked a dream.

Allen Browne said:
If you use a command button, it has focus when clicked, and Access cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

in message
I want to add the Insert hyperlink function to a command button on a form,
at
present I have a field on a form that requires a different hyperlink for
each
record so the user, click ito the field then selects the insert hyperlink
button on the tooldbar, but i want to remove this toolbar and have a
command
button the form itself to simply open the insert hyperlink dialgouse box,
I
have tried a macro and run command, but its doesn't seem to work, it seems
really simple but cant get it working, any ideas, many thanks
 
G

Guest

Hi again, works fine but if a user decides to not add a link, they cant find
it for some reason and need to come out of it, it gives a VB error and
debugs, any ideas to stop this, thanks again

Allen Browne said:
If you use a command button, it has focus when clicked, and Access cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

in message
I want to add the Insert hyperlink function to a command button on a form,
at
present I have a field on a form that requires a different hyperlink for
each
record so the user, click ito the field then selects the insert hyperlink
button on the tooldbar, but i want to remove this toolbar and have a
command
button the form itself to simply open the insert hyperlink dialgouse box,
I
have tried a macro and run command, but its doesn't seem to work, it seems
really simple but cant get it working, any ideas, many thanks
 
A

Allen Browne

Use error-handling the trap and ignore the error.

At a guess, it's probably error 2501, but you can test it by checking the
value of Err.Number.

If error-handling is a new concept, see:
http://allenbrowne.com/ser-23a.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
Hi again, works fine but if a user decides to not add a link, they cant
find
it for some reason and need to come out of it, it gives a VB error and
debugs, any ideas to stop this, thanks again

Allen Browne said:
If you use a command button, it has focus when clicked, and Access cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

"Matt, Sheffield, UK" <Matt, Sheffield, (e-mail address removed)>
wrote
in message
I want to add the Insert hyperlink function to a command button on a
form,
at
present I have a field on a form that requires a different hyperlink
for
each
record so the user, click ito the field then selects the insert
hyperlink
button on the tooldbar, but i want to remove this toolbar and have a
command
button the form itself to simply open the insert hyperlink dialgouse
box,
I
have tried a macro and run command, but its doesn't seem to work, it
seems
really simple but cant get it working, any ideas, many thanks
 
G

Guest

Sorry allen, error handling is new to me, looked at your link, but still over
the top of my head, can you tell me where this goes, in the same private sub
as my run command, could you give me an example using the run comman dyou
gave me, you have been a big help already thanks

Matt

Allen Browne said:
Use error-handling the trap and ignore the error.

At a guess, it's probably error 2501, but you can test it by checking the
value of Err.Number.

If error-handling is a new concept, see:
http://allenbrowne.com/ser-23a.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
Hi again, works fine but if a user decides to not add a link, they cant
find
it for some reason and need to come out of it, it gives a VB error and
debugs, any ideas to stop this, thanks again

Allen Browne said:
If you use a command button, it has focus when clicked, and Access cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

"Matt, Sheffield, UK" <Matt, Sheffield, (e-mail address removed)>
wrote
in message
I want to add the Insert hyperlink function to a command button on a
form,
at
present I have a field on a form that requires a different hyperlink
for
each
record so the user, click ito the field then selects the insert
hyperlink
button on the tooldbar, but i want to remove this toolbar and have a
command
button the form itself to simply open the insert hyperlink dialgouse
box,
I
have tried a macro and run command, but its doesn't seem to work, it
seems
really simple but cant get it working, any ideas, many thanks
 
A

Allen Browne

Something like this:

Sub Sub cmdInsertLink_Click()
On Error GoTo Err_Handler

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox Err.Number & ": " & Err.Description
End If
Resume Exit_Handler
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
Sorry allen, error handling is new to me, looked at your link, but still
over
the top of my head, can you tell me where this goes, in the same private
sub
as my run command, could you give me an example using the run comman dyou
gave me, you have been a big help already thanks

Matt

Allen Browne said:
Use error-handling the trap and ignore the error.

At a guess, it's probably error 2501, but you can test it by checking the
value of Err.Number.

If error-handling is a new concept, see:
http://allenbrowne.com/ser-23a.html

in
message
Hi again, works fine but if a user decides to not add a link, they cant
find
it for some reason and need to come out of it, it gives a VB error and
debugs, any ideas to stop this, thanks again

:

If you use a command button, it has focus when clicked, and Access
cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something
like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

"Matt, Sheffield, UK" <Matt, Sheffield, (e-mail address removed)>
wrote
in message
I want to add the Insert hyperlink function to a command button on a
form,
at
present I have a field on a form that requires a different hyperlink
for
each
record so the user, click ito the field then selects the insert
hyperlink
button on the tooldbar, but i want to remove this toolbar and have a
command
button the form itself to simply open the insert hyperlink dialgouse
box,
I
have tried a macro and run command, but its doesn't seem to work, it
seems
really simple but cant get it working, any ideas, many thanks
 
G

Guest

thanks again Allen, worked great

Matt

Allen Browne said:
Something like this:

Sub Sub cmdInsertLink_Click()
On Error GoTo Err_Handler

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox Err.Number & ": " & Err.Description
End If
Resume Exit_Handler
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
Sorry allen, error handling is new to me, looked at your link, but still
over
the top of my head, can you tell me where this goes, in the same private
sub
as my run command, could you give me an example using the run comman dyou
gave me, you have been a big help already thanks

Matt

Allen Browne said:
Use error-handling the trap and ignore the error.

At a guess, it's probably error 2501, but you can test it by checking the
value of Err.Number.

If error-handling is a new concept, see:
http://allenbrowne.com/ser-23a.html

in
message
Hi again, works fine but if a user decides to not add a link, they cant
find
it for some reason and need to come out of it, it gives a VB error and
debugs, any ideas to stop this, thanks again

:

If you use a command button, it has focus when clicked, and Access
cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something
like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

"Matt, Sheffield, UK" <Matt, Sheffield, (e-mail address removed)>
wrote
in message
I want to add the Insert hyperlink function to a command button on a
form,
at
present I have a field on a form that requires a different hyperlink
for
each
record so the user, click ito the field then selects the insert
hyperlink
button on the tooldbar, but i want to remove this toolbar and have a
command
button the form itself to simply open the insert hyperlink dialgouse
box,
I
have tried a macro and run command, but its doesn't seem to work, it
seems
really simple but cant get it working, any ideas, many thanks
 
G

Guest

Thanks Allen Browne, this is exactly what I was looking for.

Regards

AY

Allen Browne said:
Something like this:

Sub Sub cmdInsertLink_Click()
On Error GoTo Err_Handler

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

Exit_Handler:
Exit Sub

Err_Handler:
If Err.Number <> 2501 Then
MsgBox Err.Number & ": " & Err.Description
End If
Resume Exit_Handler
End Sub

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

message
Sorry allen, error handling is new to me, looked at your link, but still
over
the top of my head, can you tell me where this goes, in the same private
sub
as my run command, could you give me an example using the run comman dyou
gave me, you have been a big help already thanks

Matt

Allen Browne said:
Use error-handling the trap and ignore the error.

At a guess, it's probably error 2501, but you can test it by checking the
value of Err.Number.

If error-handling is a new concept, see:
http://allenbrowne.com/ser-23a.html

in
message
Hi again, works fine but if a user decides to not add a link, they cant
find
it for some reason and need to come out of it, it gives a VB error and
debugs, any ideas to stop this, thanks again

:

If you use a command button, it has focus when clicked, and Access
cannot
insert the link into the button.

Set focus to the correct text box, and it should work. Try something
like
this in the button's Click event procedure:

Me.[NameOfYourHyperlinkFieldHere].SetFocus
RunCommand acCmdInsertHyperlink

"Matt, Sheffield, UK" <Matt, Sheffield, (e-mail address removed)>
wrote
in message
I want to add the Insert hyperlink function to a command button on a
form,
at
present I have a field on a form that requires a different hyperlink
for
each
record so the user, click ito the field then selects the insert
hyperlink
button on the tooldbar, but i want to remove this toolbar and have a
command
button the form itself to simply open the insert hyperlink dialgouse
box,
I
have tried a macro and run command, but its doesn't seem to work, it
seems
really simple but cant get it working, any ideas, many 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

Top