Results 1 to 6 of 6
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    using FollowHyperlink

    Hi

    not sure if this is the correct forum for this but...

    After searching the web I found many sites pointing out that Access hyperlinks could prove to be a nightmare - as proved the case for me!

    So I discovered a forum with the following method.

    1.Create a text box and input any link as text.

    2. In the onclick event of the text box use followhyperlink to visit the web page.

    So I visited MSDN and formulated the following simple code by selecting the onclick event of the text box

    Code:
    Private Sub map_Click()
    DoCmd.FollowHyperlink
    End Sub
    If I run this to my lack of surprise I get this error



    Compile error method or Data Member not found.

    I'm assuming that this means it does not find the hyper link to use?

    If so how to I set (in my case) tblDeceased.map to be the source hyperlink?

    with 37600 records manual input is a no go

    many thanks

    Ian

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    Paste this code into a module, and it will open ANY file in its native application, including hyperlinks.

    usage: OpenNativeApp "www.google.com"
    will open it in your iExplorer (or default)
    also
    OpenNativeApp "c:\folder\file.doc"
    will open the doc in Word, etc.

    Code:
    'Attribute VB_Name = "modNativeApp"
    'Option Compare Database
    Option Explicit
    
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As String, ByVal lpszFile As String, ByVal lpszParams As String, ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long
    
    Private Declare Function GetDesktopWindow Lib "user32" () As Long
    Const SW_SHOWNORMAL = 1
    Const SE_ERR_FNF = 2&
    Const SE_ERR_PNF = 3&
    Const SE_ERR_ACCESSDENIED = 5&
    Const SE_ERR_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    Const SE_ERR_ASSOCINCOMPLETE = 27&
    Const SE_ERR_DDETIMEOUT = 28&
    Const SE_ERR_DDEFAIL = 29&
    Const SE_ERR_DDEBUSY = 30&
    Const SE_ERR_NOASSOC = 31&
    Const ERROR_BAD_FORMAT = 11&
    
    
    Public Sub OpenNativeApp(ByVal psDocName As String)
    Dim r As Long, msg As String
    
    r = StartDoc(psDocName)
    If r <= 32 Then
        'There was an error
        Select Case r
            Case SE_ERR_FNF
                msg = "File not found"
            Case SE_ERR_PNF
                msg = "Path not found"
            Case SE_ERR_ACCESSDENIED
                msg = "Access denied"
            Case SE_ERR_OOM
                msg = "Out of memory"
            Case SE_ERR_DLLNOTFOUND
                msg = "DLL not found"
            Case SE_ERR_SHARE
                msg = "A sharing violation occurred"
            Case SE_ERR_ASSOCINCOMPLETE
                msg = "Incomplete or invalid file association"
            Case SE_ERR_DDETIMEOUT
                msg = "DDE Time out"
            Case SE_ERR_DDEFAIL
                msg = "DDE transaction failed"
            Case SE_ERR_DDEBUSY
                msg = "DDE busy"
            Case SE_ERR_NOASSOC
                msg = "No association for file extension"
            Case ERROR_BAD_FORMAT
                msg = "Invalid EXE file or error in EXE image"
            Case Else
                msg = "Unknown error"
        End Select
    '    MsgBox msg
    End If
    End Sub

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe use a button click event?
    Code:
    Dim strPath As String
    strPath = Me.NameOfTextBox.Value
    FollowHyperlink strPath

  4. #4
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by Jen0dorf View Post
    Hi

    not sure if this is the correct forum for this but...

    After searching the web I found many sites pointing out that Access hyperlinks could prove to be a nightmare - as proved the case for me!

    So I discovered a forum with the following method.

    1.Create a text box and input any link as text.

    2. In the onclick event of the text box use followhyperlink to visit the web page.

    So I visited MSDN and formulated the following simple code by selecting the onclick event of the text box

    Code:
    Private Sub map_Click()
    DoCmd.FollowHyperlink
    End Sub
    If I run this to my lack of surprise I get this error

    Compile error method or Data Member not found.

    I'm assuming that this means it does not find the hyper link to use?

    If so how to I set (in my case) tblDeceased.map to be the source hyperlink?

    with 37600 records manual input is a no go

    many thanks

    Ian
    Ian,

    I think what you are wanting to do is open the link in the textbox named map when you click on it.

    Your code is close. You need to add a parameter to the followhyperlink command with the data in the text box.

    Try:

    Code:
    Private Sub map_Click()
    DoCmd.FollowHyperlink Me.map
    End Sub

  5. #5
    Jen0dorf is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    as usual thanks to one and all

    Ian

  6. #6
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 8 Access 2013
    Join Date
    Jul 2010
    Location
    Oklahoma, USA
    Posts
    702
    Quote Originally Posted by Jen0dorf View Post
    Hi

    as usual thanks to one and all

    Ian

    You're welcome! Glad we could assist.

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

Similar Threads

  1. Application.FollowHyperlink throwing Exception
    By Mnelson in forum Programming
    Replies: 4
    Last Post: 03-19-2015, 02:13 PM
  2. Replies: 3
    Last Post: 06-23-2013, 05:29 PM
  3. FollowHyperlink Help
    By RachelBedi in forum Access
    Replies: 6
    Last Post: 01-18-2013, 08:22 AM
  4. Reference is not valid FollowHyperlink error
    By kevint_cnc in forum Access
    Replies: 2
    Last Post: 09-04-2012, 02:22 AM
  5. Set IE window size using followhyperlink
    By AndrewAfresh in forum Access
    Replies: 0
    Last Post: 11-23-2006, 12:22 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