Solved

Hyperlink Not Working in Unbound Textbox

Posted on 2003-12-03
8
1,669 Views
Last Modified: 2007-12-19

I'm using unbound forms which use code to load data from tables and/or queries into the forms' various controls, mostly being textboxes.  Currently I have a Access 2000 mdb but expect later to move to SQL Server, and thus want to store hyperlinks as text data types rather than hyperlink data types (trying to reduce conversion headaches later).  I can't seem to get the hyperlinks to work.  Here's what I've done:

- I set the textbox's IsHyperlink property to True.  
- The textbox is unbound.
- I make the hyperlink value assignment to the textbox in code, in the form of:
      .... code gets hyperlink value from table...
      Me.txtHyper = "Wyatt#mailto: Wyatt@anyplace.com"    
- The textbox displays "Wyatt#mailto: Wyatt@anyplace.com" in blue underline, like a hyperlink.  But it doesn't display the "Wyatt" part alone as it normally should.
- When I go to the textbox, the pointed-finger icon doesn't appear and when I click nothing happens.

FYI, I've tried different variations of the hyperlink syntax, all with the same results.  

Any ideas on where I'm going wrong?

Thx,
Wyatt



0
Comment
Question by:WyattRidesAgain
  • 5
  • 3
8 Comments
 
LVL 18

Expert Comment

by:bonjour-aut
ID: 9869497
Do this VBA:

Private Sub txtHyper_Click
 Application.FollowHyperlink(Me.txtHyperlink)
End Sub

assuming that the hyperlink is correct in the texbox

Regards, Franz
0
 
LVL 18

Accepted Solution

by:
bonjour-aut earned 250 total points
ID: 9869515
there is more sophisticated code too, if you prefer

you can paste that code to a module and use this publich function:

Public Function OpenHLink(target As String)
  Dim targeturl As String
  Dim linktype As Integer
  linktype = 0 'default
  If InStr(1, target, "\") > 0 Then linktype = 1 'local
  If InStr(1, target, "@") > 0 Then linktype = 2 'mail vv
  If InStr(1, target, "http://") > 0 Then linktype = 3 'tranparent
  Select Case linktype
   Case 0
      targeturl = "http://" & target
   Case 1, 3
      targeturl = target
   Case 2
      targeturl = "mailto:" & target
  End Select
  Application.FollowHyperlink (targeturl)
End Function

Regards, Franz
0
 

Author Comment

by:WyattRidesAgain
ID: 9870457
Franz,

Thanks for both the simple and the sophisticated versions of using Application.FollowHyperlink().  Very nice!  

But how do I get the mouse icon to change to the normal hyperlink pointer when it's over the textbox?  This is something that users always expect with hyperlinks.

Regards,
Wyatt
0
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 
LVL 18

Expert Comment

by:bonjour-aut
ID: 9870848
Set The Hyperlink Property to true and asign the value to # without any quotes

the # stands for selfreference, so the built in hyperlink does not fire and the _Click event can fire

Regards, Franz
0
 

Author Comment

by:WyattRidesAgain
ID: 9871618
Franz,

Sorry, but I don't quite follow your comments about assigning a value to # and not having quotes.  Could you explain a bit more, or offer a code snippet to illustrate?

Much thanks,
Waytt
0
 
LVL 18

Expert Comment

by:bonjour-aut
ID: 9872755
Have a look at this example:

http://www.tplus.at/~sissi-franz/test/wwwhyperlink.mdb

on the testform you will find "otherLabeMethod"

look at its properties - this shows, what i mean

Regards, Faranz
0
 
LVL 18

Expert Comment

by:bonjour-aut
ID: 9872855
to change the mouse cursor over a text-field to a hand is a problem, as there is no hand in the mouse-poiter properties ( Screen.MousePointer = 1,3,..,11)

there is a pssibility for a custom one.
see http://p2p.wrox.com/archive/vba_access/2001-05/10.asp

regards, Franz
0
 

Author Comment

by:WyattRidesAgain
ID: 9881449

Franz,

Thanks for the help.  That gets me going!  Points are coming.

Regards,
Wyatt
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question