Filter/requery a subform based on active record of another subform

G

Guest

Imagine if you will....

I have three forms combined together to create a common workspace.

I have a parent form "frm_BaseForm"
On this form I have two subforms "frm_LeftForm" and,
"frm_RightForm" both using the the same table as its record source.

The frm_LeftForm has a summary listing of all records in the table, the
frm_RightForm provides detailed information on a single record from the same
table. The idea is to keep frm_RightForm in synch with the selected record in
frm_LeftForm. The fields on each form that are to synch are both called "ID"

My strategy was to leverage the "Enter" event of the frm_LeftForm record to
cause a filter, and possibly requery, of frm_RightForm - filtering by the
shared "ID."
The following is basically what I was trying, but I don't seem to be
referencing frm_RightForm correctly as I get a VBA error saying it can't find
the form....

Private Sub ID_Enter()

Dim strFilter As String
MsgBox strFilter <----Just to show I am acquiring the correct ID
strFilter = "ID = " & ID
Forms!frm_RightForm.Filter = strFilter

End Sub


Any ideas?
 
M

Malcolm Cook

tfossum,

do frm_LeftForm and frm_RightForm have the same recordsource, but just
display have differently ? (i.e. frm_LeftForm in a continuous form or
datasheet, and the frm_RightForm one in 'Single Form')?

If so, then, all you have to do to get your sync behaviour is to make the
forms have the SAME record set.

I'm not sure about the timing in your case, but, try this: put a button on
your parent that does the following

set frm_LeftForm.RecordSet = frm_RightForm.Recordset

If that implements your behaviour, then, just figure out the timing of when
to do this... (the rub: I don't think that subforms are not 'there' yet
during the parent forms initial open/load/active/current cycle).

HTH,
 

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