wintermute
wintermute

Reputation: 129

Userfriendly forms for links in MS Access

I'm trying to create a form with the following behavior:

  1. Clicking it when it's empty opens the dialogue window of inserting a hyperlink
  2. Clicking it when there's a hyperlink opens the hyperlink
  3. Clicking a nearby "Clear" button clears the form deleting the hyperlink (if present)

I'm currently stuck with step 2. The code for hyperlink insertion window is this one:

Private Sub PSIC_Click()
Me.[PSIC].SetFocus
On Error GoTo browse_stop
RunCommand acCmdInsertHyperlink
browse_stop:
End Sub

When I try to apply different if then variations it doesn't work as expected. Either I fail in properly applying if then or in determining that the form is empty.

Upvotes: 1

Views: 112

Answers (2)

MoondogsMaDawg
MoondogsMaDawg

Reputation: 1714

The OnClick() event of your hyperlink textbox would be:

Private Sub PSIC_Click()
On Error GoTo browse_stop
If ISNULL(Me!PSIC) Then
  RunCommand acCmdInsertHyperlink
End If
browse_stop:
End Sub

I removed SetFocus because clicking on the textbox should automatically set the focus, but if you need it there for some other reason it wasn't really hurting anything.

The "Clear form" command button's OnClick() event would be:

Private Sub cmdClearForm_Click()
Me!PSIC = NULL
End Sub

Upvotes: 2

Jenna
Jenna

Reputation: 3

To open a hyperlink from a form in MS Access:

In Design View make sure that the hyperlink is in its own text box and then go to the 'property sheet' then half way down you should see the option for Hyperlink Address. In here add the address of the hyperlink.

If you want to click on an image and have it open a hyperlink then right-click on the image go to hyperlink.

Upvotes: 0

Related Questions