Control a form with a subform?

M

Max Moor

Hi All,

In the past, I[ve done a lot of forms where the form's query filtered
on a listbox on the form. Select the record of interest from the listbox,
requery the form from the listbox's click event, and get access to the
records detail info in the form.

Is there a simple way to do this using a subform instead of a listbox?
I've mocked it up, but find that when I click a record in the subform and
requery the main form, the subform also requeries, and I lose the record I
was at in the first place. I can save the record ID, then scroll the subform
backl to it after requerying the main form, but this seems ugly.

Is there a simpler way?

Regards,
Max
 
A

Amy Blankenship

Max Moor said:
Hi All,

In the past, I[ve done a lot of forms where the form's query filtered
on a listbox on the form. Select the record of interest from the listbox,
requery the form from the listbox's click event, and get access to the
records detail info in the form.

Is there a simple way to do this using a subform instead of a listbox?
I've mocked it up, but find that when I click a record in the subform and
requery the main form, the subform also requeries, and I lose the record I
was at in the first place. I can save the record ID, then scroll the
subform
backl to it after requerying the main form, but this seems ugly.

By definition, records in subforms should be related to a parent record in
the main form. Hence, if you are on a record in the subform, the main form
should already be at the correct record. It sounds like you're using the
subform in a different way, so could you please explain what you have?
 
M

Max Moor

By definition, records in subforms should be related to a parent record
in the main form. Hence, if you are on a record in the subform, the
main form should already be at the correct record. It sounds like
you're using the subform in a different way, so could you please explain
what you have?

Hi Amy,
I want to drive the current record on the main form by selecting from a
list of records, but using a subform instead of a combobox or listbox. The
advantage of doing this for me is that I can edit data in the list as well as
the form.
-Max
 
K

Ken Sheridan

Max:

Use two correlated subforms, one in single form view (for the full details)
and one in continuous form view. Put both of these in an unbound parent form
and in the parent form put a text box with its Visible property set to False
(No) and its ControlSource a reference to a control in the continuous view
subform bound to its primary key, referencing the control via the Form
property of the subform control, e.g.

=[YourSubformControl].Form![YourID]

Note that YourSubformControl is the name of the control on the parent form
which houses the continuous view subform, not the name of its underlying form
object.

Set the LinkMasterFields property of the single view subform control to the
name of the hidden text box, e.g. txtYourIDHidden, and the LinkChildFields
property to the name of the primary key of the single view form's underlying
table, e.g. YourID.

As you navigate from row to row in the continuous subform the single form
view subform should automatically be filtered to the matching record.

Ken Sheridan
Stafford, England
 
M

Max Moor

Max:

Use two correlated subforms, one in single form view (for the full
details) and one in continuous form view. Put both of these in an
unbound parent form and in the parent form put a text box with its
Visible property set to False (No) and its ControlSource a reference to
a control in the continuous view subform bound to its primary key,
referencing the control via the Form property of the subform control,
e.g.

=[YourSubformControl].Form![YourID]

Note that YourSubformControl is the name of the control on the parent
form which houses the continuous view subform, not the name of its
underlying form object.

Set the LinkMasterFields property of the single view subform control to
the name of the hidden text box, e.g. txtYourIDHidden, and the
LinkChildFields property to the name of the primary key of the single
view form's underlying table, e.g. YourID.

As you navigate from row to row in the continuous subform the single
form view subform should automatically be filtered to the matching
record.

Ken Sheridan
Stafford, England


Hi Ken,

That's it! It never occurred to me. Thanks so much.

Regards,
Max
 
A

Amy Blankenship

Max Moor said:
Hi Amy,
I want to drive the current record on the main form by selecting from a
list of records, but using a subform instead of a combobox or listbox.
The
advantage of doing this for me is that I can edit data in the list as well
as
the form.

Yes, Mrs. Lincoln, but how was the play?

What exactly is your setup? What do you have in link parent/link child?
 

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

Similar Threads

Subform Data Entry Setting 0
Requery listbox 1
Display subform total 1
Problem with form--subform 5
Access Main form/Subform Navigation 0
Form -> Subform 5
Requery unbound textbox 1
Refreshing a subform 3

Top