Code Examples

Open Hyperlink in New Window

acCmdOpenNewHyperlink

Use this example to open the hyperlink in a new window. This example assumes that you have a text field called txtHyperlink and that the code is behind a command button called cmdOpenNewHyper.

'***************** Code Start *******************
' Code by Terry Wickenden

Private Sub cmdOpenNewHyper_Click()
  On Error Goto ErrOpenNewHyper
  Me.txtHyperlink.SetFocus
  DoCmd.RunCommand acCmdOpenNewHyperlink
  Exit Sub
ErrOpenNewHyper:
  Select Case Err
    Case 2046
      'Menu option not available
      'Normally because there is nothing to link to
      MsgBox "There is no hyperlink"
    Case Else
      MsgBox Err & vbCrLf & vbCrLf & Err.Description, vbCritical, "Error Message"
      Resume
  End Select
End Sub

'****************** Code End ********************

© 1998 - 2011 Terry Wickenden TKW Design Site developed, maintained and hosted by TKW Design. This site is best viewed at 1024 x 768. Optimised for Firefox.