Results 1 to 8 of 8
  1. #1
    carterlangley is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Rothienorman, Scotland
    Posts
    15

    Visual Basic Chr() usage and formatting of hyperlinks

    Hi all,



    OK, so here is my code.
    Code:
    ="Home Phone " & [HomePhone] & Chr(13)+Chr(10) & "Mobile Phone " & [MobileNumber] & Chr(13)+Chr(10) & "Email Address " & [ClientEmailAddress]
    So far so good. It brings it all in. Problem I'm having is with the display of the email address. It has that annoying 'mailto:'. What would be ideal would be the ability to display the hyperlink, whether email or web, as a hyperlink instead of just plain text. Is this possible using the above code? Must be a way to do this. I'm going to be adjusting the code to include the iif statements to cover myself for information that is not entered.

    Hope you geniuses out there can help!

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    If you want to continue using a hyperlink field, you could try using Mid([ClientEmailAddress],8) to lose the first part but I suspect it will no longer act as a hyperlink
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    carterlangley is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Rothienorman, Scotland
    Posts
    15
    Hi ridders52

    Apparently there is a hyperlink.address property in access.

    so, format is something like expression.Address
    I'll try using your mid statement as the expression part and append the .Address to it and see if that works. I'll get back to you on the result once my old brain has figured out the syntax.

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    You didn't say how and where you want to use this.

    Personally, if this is on a form or report, I would but use 3 textboxes and labels for the captions
    Hyperlink fields are problematic as they consist of two parts
    I would instead use a text field for the email address and add Application.FollowHyperlink code to the textbox click event
    You can easily format it to look like a hyperlink field.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    carterlangley is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Rothienorman, Scotland
    Posts
    15
    Nope, that didn't work. Still getting that mailto: and it isn't behaving as a hyperlink (one click sends you to the ether). I think I am being a bit ambitious here for Access. For email addresses and hyperlinks I think the best and easiest is to drag and drop from the field list onto the report or form. There is probably a workaround using a custom function but that is beyond my capabilities at the moment. I don't want to get into re-inventing the wheel quite yet hahahahaha

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Have you tried doing what I suggested in my second reply as that will definitely work
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  7. #7
    carterlangley is offline Novice
    Windows 10 Access 2016
    Join Date
    Jan 2018
    Location
    Rothienorman, Scotland
    Posts
    15
    Yes, I tried that but couldn't get it to work or display properly.
    I seem to recall that hyperlinks do consist of two parts (even 3 maybe?), but it has been at least 20 years since I've programmed in VB and I've lost my touch. You're saying format the entry in the table as plain text and then use the click event to tell Access to treat it as a hyperlink. Makes sense that way, getting rid of the different parts. This is going onto a report, but I suppose the same rules will apply for forms as well in the most cases. Thanks for helping out, hopefully something in this old brain of mine clicks and I start remembering more of VB.

  8. #8
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    Here's an example from one of my apps:

    Click image for larger version. 

Name:	Capture.PNG 
Views:	7 
Size:	11.8 KB 
ID:	32864

    The third line down has a textbox which uses a function GetSupportEmail to retrieve an email address from a settings table
    It is formatted to look like a hyperlink
    NOTE: The actual email address could be used insteador a field containing the address

    Clicking on that textbox runs this code:

    Code:
    Private Sub txtEmail_Click()    Application.FollowHyperlink "mailto:" & GetSupportEmail()
    End Sub
    This opens the default email application with the address in the 'To' field of a blank email

    HTH
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Help with Rounding in Visual Basic
    By UTLee in forum Programming
    Replies: 4
    Last Post: 12-16-2014, 05:05 PM
  2. Visual Basic
    By Darth21 in forum Access
    Replies: 4
    Last Post: 08-11-2014, 06:18 AM
  3. Visual Basic
    By kwooten in forum Queries
    Replies: 2
    Last Post: 01-25-2012, 08:22 AM
  4. trying to learn visual basic
    By darklite in forum Programming
    Replies: 7
    Last Post: 08-24-2011, 02:18 PM
  5. Record Value in Visual Basic
    By chrismec in forum Programming
    Replies: 3
    Last Post: 12-09-2009, 04:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums