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?
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
will open the doc in Word, etc.
'Attribute VB_Name = "modNativeApp"
'Option Compare Database
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
msg = "File not found"
msg = "Path not found"
msg = "Access denied"
msg = "Out of memory"
msg = "DLL not found"
msg = "A sharing violation occurred"
msg = "Incomplete or invalid file association"
msg = "DDE Time out"
msg = "DDE transaction failed"
msg = "DDE busy"
msg = "No association for file extension"
msg = "Invalid EXE file or error in EXE image"
msg = "Unknown error"
' MsgBox msg