Editing Hyperlink field (1 Viewer)

access7

Registered User.
Local time
Today, 04:49
Joined
Mar 15, 2011
Messages
172
Hello

Just a quick question; I have a field in my Contacts table for 'Website'. I have set this field in the table as a hyperlink field.
When the user enters the website address on the form this then appears as a hyperlink and will take them to the appropriate website when clicked - all good.

The problem I am having is that is a contact were to change their email address and the user tried to click in the box to 'edit the hyperlink' it just keeps following the link to the web address.

I know you can right click and choose to 'edit hyperlink' but is there a 'more obvious' way for my user to edit the text in that field.

I was thinking of an on click event on the edit button I could temporarily change the data type for the field making it editable (so the user can just type the new website address in the field).

Does anyone have any idea how I would do this or a better suggestion for me at all...

I am quite new to using hyperlinks so this one is baffling me a bit :confused:

Thanks in anticipation
 

Trevor G

Registered User.
Local time
Today, 04:49
Joined
Oct 1, 2009
Messages
2,341
F2 on the field name is Edit. Will that work for you?
 

access7

Registered User.
Local time
Today, 04:49
Joined
Mar 15, 2011
Messages
172
It would when I'm in the table but I am looking for a solution for the user (who only see / have access to the forms).

Thanks
 

access7

Registered User.
Local time
Today, 04:49
Joined
Mar 15, 2011
Messages
172
Yes but I think you have to have 'clicked in' or selected the field to begin with - which is when it then follows the hyperlink... appologies if I am getting this wrong?
I appreciate the help :)
 

Trevor G

Registered User.
Local time
Today, 04:49
Joined
Oct 1, 2009
Messages
2,341
If the tab key is used to move to the fields on your form F2 works.
 

access7

Registered User.
Local time
Today, 04:49
Joined
Mar 15, 2011
Messages
172
Thank you again for the suggestion, it is something I was unaware of so I thank you for bringing it to my attention. Will be useful for me.

As for the wesbite field for my users I really am looking for a way that they can press the Edit button and then click straight into the website field to edit the text. Is this at all possible?

Do you know of any other way... I am trying to make this as simple as posisble for the user - I think if they have to remember to first of all use tab rather than mouse click (most of the employees here do not use the tab key) and then second of all remember the key F2 to press... they may get confused.

Many Thanks
 

pr2-eugin

Super Moderator
Local time
Today, 04:49
Joined
Nov 30, 2011
Messages
8,494
Hi there.. Not sure how great this will work for you.. But it is worth the try..
Code:
Private Sub LinkA_Click()
Dim retval
retval = MsgBox("If you wish to Open the link click 'Yes' (or) to Edit the address click 'No'?", vbYesNo + vbQuestion)
If retval = vbNo Then
    Dim txtVal As String
    txtVal = LinkA.Value
    LinkA.Value = ""
    Call replaceValue(txtVal)
End If
End Sub

Private Sub replaceValue(txtVal As String)
    LinkA.Value = InputBox("Please edit the data in the box below", "Edit address", txtVal)
End Sub
 

Trevor G

Registered User.
Local time
Today, 04:49
Joined
Oct 1, 2009
Messages
2,341
What about making the field a text field and use the form label as the hyperlink that they click on?
 

JoshTurnbull

New member
Local time
Yesterday, 20:49
Joined
Feb 21, 2013
Messages
3
My solution to hyperlinking a field that needs to be edited by the user is to set the 'is hyperlink' property to no, and to put an event procedure into the control's double click event to go to the desired link. This means that a single click will allow the user to edit the field with no troubles. It can also help to set the 'display as hyperlink' property to 'always', which will mean the user can see no difference.

Also, for posterity, there is a microsoft support article on this (can't link at the moment).
 

cjrhoads

Registered User.
Local time
Yesterday, 23:49
Joined
Nov 27, 2013
Messages
14
Hi. Thanks for answering the exact question I have (though this thread is a bit old).

Could you please clarify, however? What I would really love is sample code that you used in the double click event.
In my case I have a field call PrimaryWebPage.
It might, for example, have the contents h t t p : / / etmassociates.com
(I had to put it in so that it didn't become a link because apparently I can't post a link)

I want to make it easier for the user to edit it, and I loved your suggestion of making it editable with a single click and a hyperlink with a double click, but I don't know the syntax for the code. Would it just be

<a href= Me.PrimaryWebPage a>

Or is there something else that I would have to do in order to translate the hyperlink text to an actual hyperlink?

Any help that you can give would be much appreciated.

Thanks
CJ
 

JoshTurnbull

New member
Local time
Yesterday, 20:49
Joined
Feb 21, 2013
Messages
3
Just use

Code:
Application.FollowHyperlink [control name].value

in the double-click event if the control's value would typically be a URL. You may need to throw in some error handling as I can't remember off the top of my head how exceptions are handled if a URL isn't valid.

If you want the value to show a non-URL value but still be a hyperlink, you'll probably have to put a command to open a modal form with both the displayed value and the URL value. For this option I would put this in the double-click event and the followhyperlink command in the on-click event. (But following the URL, not the displayed value, obviously)
 

cjrhoads

Registered User.
Local time
Yesterday, 23:49
Joined
Nov 27, 2013
Messages
14
Hmmm - Thanks, Josh. The code that you gave me to make the double click follow the hyperlink may work, but I can't tell because I can't get the hyperlink not to follow on the single click. I have set the Is Hyperlink property to No, but the field still shows as a hyperlink and trying to click into the field still immediately follows the hyperlink without any chance to edit. The field type is hyperlink - should that be set to text or memo instead?
 

JoshTurnbull

New member
Local time
Yesterday, 20:49
Joined
Feb 21, 2013
Messages
3
Ah, then yes you will need to make it a text or memo field.

Essentially what you're trying to do here is have Access treat the value in the control as just a string and control the hyperlink process yourself through VBA. The problem at the moment is that Access is assuming that a user seeing a hyperlink will want to follow it when clicking on it - if Access just thinks its a meaningless string, no action will be taken when a user clicks on the value.
 

cjrhoads

Registered User.
Local time
Yesterday, 23:49
Joined
Nov 27, 2013
Messages
14
Okay - I've made it a memo field. (I'm afraid that 255 characters would not be enough for some hyperlinks.) It works like a charm!!

Of course, when I originally switched the field from hyperlink to text, Access did some wierd things, turning every link into a double, as in www.website.com#http://www.website.com#, but I just threw everything into an Excel spreadsheet and did a Text To Columns using the numbers sign as a delimiter and copied it back into the Access field.

You are terrific. Thanks.
 

Users who are viewing this thread

Top Bottom