Hyperlink Access Form from Layer Property using Python

217
0
03-06-2014 12:37 PM
JoydipMajumder
New Contributor
Hello There,
In ArcGIS, I wanted to have a system: when I click on a point, it will follow a hyperlink and will open up a specific Access Form based on the attribute I clicked. I had a VBA code for ArcGIS 9.1 but since I upgraded into ArcGIS 10.1, it seems that I have to switch to Python (VBA license is separate). Does anyone know of any available code? Thanks in advance! Below is the VBA code I was following (Thanks to Kristina Callahan)!

Declare Function ShellExecute Lib "shell32.dll" Alias _
   "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation _
   As String, ByVal lpFile As String, ByVal lpParameters _
   As String, ByVal lpDirectory As String, ByVal nShowCmd _
   As Long) As Long

Declare Function apiFindWindow Lib "User32" Alias "FindWindowA" _
   (ByVal lpclassname As Any, ByVal lpCaption As Any) As Long

Global Const SW_SHOWNORMAL = 1

Sub Hyperlink(pLink, pLayer)

On Error GoTo eh:

    Dim pHyperlink As IHyperlink
    Set pHyperlink = pLink
    Dim pFLayer As IFeatureLayer
    Set pFLayer = pLayer
    Dim thestring As String
    thestring = pHyperlink.Link

    Dim hwnd
    Dim StartDoc
    hwnd = apiFindWindow("OPUSAPP", "0")

    'opens Microsoft Access database
    StartDoc = ShellExecute(hwnd, "open", "I:\BU\510\550\Joydip\GIS Work\CLDatabase.accdb", "", "I:\", SW_SHOWNORMAL)

    Dim Accapp As Access.Application
    Set Accapp = GetObject("I:\BU\510\550\Joydip\GIS Work\CLDatabase.accdb")


    Accapp.DoCmd.OpenForm "InitialPage", acNormal, , ("[int_id]=" & Chr(34) & thestring & Chr(34))

    Exit Sub
   
eh:
    MsgBox "Something isn't working!"

End Sub

- Joydip
Tags (2)
0 Kudos
0 Replies