Solved

Hyperlink Not Working in Unbound Textbox

Posted on 2003-12-03
8
1,656 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
 
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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now