Continuous Form

J

jez123456

Hi, I have a main form (Media) linked to a subform (Media subform) through a
MediaID primary key.

Both forms record source is tblMedia which has a recursive relationship.

The subform is set as a continuous form, and each row has a command button
shown.

When a subrecord is selected and the button clicked I want the main form to
display the record which was selected in the subform.
 
A

Allen Browne

Presumably your Media table has another field that links to MediaID. Perhaps
it's called ParentID, so a record can be related to a parent record in the
same table. So the subform control would have MediaID as the Link Master
Fields, and ParentID as the Link Child Fields.

If that's the idea, the command button in the continuous subform would need
something like this in its Click event procedure:

Private Sub cmdGoParent_Click()
Dim rs As DAO.Recordset
Dim strWhere As String

If Me.Dirty Then Me.Dirty = False 'Save first.

If IsNull(Me.ParentID) Then
MsgBox "No parent to go to."
Else
strWhere = "MediaID = " & Me.ParentID
With Me.Parent
Set rs = .RecordsetClone
rs.FindFirst strWhere
If rs.NoMatch Then
MsgBox "Not found in parent form. Filtered?"
Else
.Bookmark = rs.Bookmark
End If
Set rs = Nothing
End With
End If
End Sub

That's aircode, but you get the idea.
 

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