Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2015

    Unanswered: Hyperlink in unbound forms?

    Hi All,

    I'm using unbound data entry forms to record interaction with stakeholders. I was wanting to use a field to insert a hyper-link to document the user may think have relevance to the interaction (copy of a letter or something).

    The docmd.runcommand accmdinserthyperlink code does not seem to work. I tested this on a bound form and it seemed to work.

    Unfortunately I need the data entry to be unbound on this database and was hoping there is a way to insert a hyperlink into an unbound text field so that it can be included in the usual .addnew/.update vba code for unbound forms?


  2. #2
    Join Date
    Apr 2014
    Provided Answers: 23
    Paste this code into a module, and it will open ANY file in its native application.

    usage: OpenNativeApp "c:\folder\file.pdf" ' will open it in acrobat
    OpenNativeApp "c:\folder\file.doc"
    will open the doc in Word, etc.

    '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_OOM = 8&
    Const SE_ERR_DLLNOTFOUND = 32&
    Const SE_ERR_SHARE = 26&
    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"
                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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts