You cannot run an event from the table. You could create a form (I will
call it frmContact) in datasheet view, which resembles a table. I will
assume this is a Contacts database, that the form you want to open is
frmMain, and that the number 25 (in your example) is in the ContactID field.
The text box bound to ContactID could have as its Click event:
DoCmd.OpenForm "frmMain", , , "ContactID = " & Me.ContactID
If ContactID is a text field:
DoCmd.OpenForm "frmMain", , , "ContactID = """ & Me.ContactID & """"
This will open frmMain to show only records in which ContactID is the same
as ContactID on frmContact.
If you want to show all records you can use the Apply Filter/Remove Filter
toolbar button, or you can have a command button with the Click event code:
Me.FilterOn = False
or, to toggle the filter property:
Me.FilterOn = Not Me.FilterOn
It is also possible to open frmMain so that it loads all records, but goes
to a specific record. In the text box Click event as described above:
Dim strArgs as String
strArgs = "ContactID = " & Me.ContactID
DoCmd.OpenForm "frmMain", OpenArgs:=strArgs
Then, in the Load event for frmMain:
If Len(Me.OpenArgs) > 0 Then
With Me.RecordsetClone
.FindFirst Me.OpenArgs
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Else ' i.e. if form is opened directly rather than from frmContacts
Me.SomeControl.SetFocus
End If
SomeControl is a control on frmMain. You do not need to set focus as I have
shown, but you may want to do something if the form is opened directly
rather than from frmContacts. If you will always open frmMain from
frmContacts you do not need the If:
With Me.RecordsetClone
.FindFirst Me.OpenArgs
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With