Field as a Hyperlink

L

Larry G.

Is there a way that I can use a filed on a form as a hyperlink to open
another form?

For instance, I have a form that lists all of the incident numbers
associated with a particular site. What I would like to do is have each field
on that form be a hyper link so that when that incident number is clicked it
will open up a new form with the information assiciated with that number.
 
R

Roger Carlson

You generally use hyperlinks to open external files, not another form in
Access.

To open another for, you could put code in the OnClick event of your textbox
to open the other form. You can also send the value of the field to the
other form via the OpenArg property of the form.

Example:

Suppose your textbox is called AuID2 and the form you want to open based on
the value in that field is "Authors". You could have something like this in
the OnClick event of AuID2

Private Sub AUID2_Click()
DoCmd.OpenForm "Authors", , , , , , AUID2.Value
End Sub

On my website (www.rogersaccesslibrary.com), is a small Access database
sample called "OpenArgs" which illustrates how to use the OpenArg value in
your opened form (though not exactly in the way your looking to do).

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
B

Ben

Hi Larry,

I think what you are referring to would be bookmarks. In my database I have
a series of lists displaying informtion related to that particular record
from other tables. I can double click on anything in the list and the other
form opens and goes directly to the record I have selected.

What you should do is construct lists which include the unique ID of the
related record as the bound column. I usually make this column invisible, so
the list only shows the related record title. So when you double click the
item in the list you are telling access the record number you wish to go to.
Here is an example of the code I use to get this done. It is placed on the
'On DoubleClick' event of the list:

On Error GoTo Err_List_Linked_Actions_DblClick
'this saves the record if it has not already been done.
If Me.Dirty Then Me.Dirty = False

stDocName = "NAME OF FORM YOU WANT TO OPEN"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Dim frm As Form
Dim strWhere As String

strWhere = "[NAME OF BOUND COLUMN] = " & Me.Listbox_Linked_Interface
Set frm = Forms![FORM YOU WANT TO OPEN]
With frm.RecordsetClone

Debug.Print strWhere

.FindFirst strWhere
If .NoMatch Then
msgbox "Not found. Is the form filtered?"
Else
'Selects and stays on record the user has come from
frm.Bookmark = .Bookmark
End If
End With

Let me know if you need some more help.
Cheers, Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top