Individual Record Subform (easy!)

ColinGrant

New member
Local time
Today, 13:17
Joined
Jun 13, 2011
Messages
3
I am fairly new to access and I am wondering about a form.

In my form, I want to have certain field values displayed based upon which row the user selects.

So, pretend a user selects Record B, I want a subform that displays data from only Record B.

Is this possible, and if so how? :)

Thanks!

Here is a quick idea of what I'm trying to do:

Form 1:

[__________RECORD A____________]
[__________RECORD B____________] (Selected)
[__________RECORD C____________]
[__________RECORD D____________]

Sub Form:

[______DISPLAY DATA FROM RECORD B HERE____]
 
You would have one unbound main form with two subforms. One showing the list and one showing the detail.

In the current event of the list you would filter the detail to show the same record as the list.

It's probably easier to do that in a public sub in the main form that the current event of the list subform will call

So, in the list subform you would have code like this:

Code:
Private Sub Form_Current()
    Me.Parent.ShowSelectedRecord
End Sub
And in the main form you would have the sub:

Code:
Public Sub ShowSelectedRecord()
     subDetail.Form.Filter = "RecordID = " & Nz(subList.Form!RecordID,0)
     subDetail.Form.FilterOn = True
End Sub

Where the two subforms (the controls not the forms themselves) are called subList and subDetail and the primary key in the table the both is called RecordID.

It's probably best not to allow edits in the list to avoid conflicting record locks.

And you're probably going to want to run ShowSelectedRecord in the current event of the main form so it shows the detail of the first record in the list at the start.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom