display subform record in main form

G

Guest

I have a main form with a subforms. I need to find a way when display a
record in the mainform while i am browsing the subform with store all the
records.

The main form can also be used to in put new record for the subform.

Thanks for any ideas. I looked at various copying codes but none go from
subform to main form.
 
A

Allen Browne

This interface is backwards to how subforms are designed.

If you are trying to use a subform to select which record you want in the
subform, can I suggest you use a list box for that purpose instead of a
subform.

1. Create a new, unbound form, and add a list box.
Set the RowSource of the list box to just the columns you need to see, plus
the primary key field as the bound column of the unbound list box
(zero-width column if you wish.)

2. Add your existing main form as a subform beside the listbox.
Set the LinkMasterFields of the subform control to the name of the listbox,
and the LinkChildFields to the primary key field name of your form.

As you select a record in the list box, the record is shown in the subform.
No code needed.
 
G

Guest

Your main form should have 2 subforms, one that will allow you to browse the
records, the second subform will display the corresponding record (single
form view), to link the 2 subforms add a textbox in the main form that refers
to the primary key of your browsing form (subform 1), then link the 2nd
subform to that text box using the link parent/child fields properties for
the 2nd subform
 
G

Guest

Hi Allen,

May i have not explain this good enough:

try again: the subform display the information data
The main form will allow the user to add the new data. But
also display the existing information in sub form(in data sheet view)
 
G

Guest

WELL,

I think because the information has always been presented like that before
from other database.
 
A

Allen Browne

hngo, I don't understand the reason you are doing this.

Is the subform intended to be the way the user can find the record you want
to display in the main form?
 
G

Guest

yes, the main form is to display the record (in form view) of the subform
records (datasheet view). you can also manually enter the in fosmation in
the mainform. If this record is not in the list of subform it will add the
record to subform.
 
A

Allen Browne

If that is the aim, you are using the idea of a subform backwards.

To achieve an interface that is the functional equivalent of what you
describe, place a list box on the main form, and use it to navigate to the
desired record. Then have Access show the detail in the subform, where you
can edit it.

Details earlier in this thread.

If that is not what you want to do, I cannot help you.
 
G

Guest

thanks Allen,

I will try your approach

Allen Browne said:
If that is the aim, you are using the idea of a subform backwards.

To achieve an interface that is the functional equivalent of what you
describe, place a list box on the main form, and use it to navigate to the
desired record. Then have Access show the detail in the subform, where you
can edit it.

Details earlier in this thread.

If that is not what you want to do, I cannot help you.
 
G

Guest

have you created the 2nd subform?, the main form will not have any record
source, it is going to be just a place holder for the textbox that will link
the 1st subform in datasheet view, and the 2nd subform in single form view,
in total you will have 3 forms, the main form, holding subforms 1 and 2, and
the field linking them together,

the text fox linking both subforms will have a control source like:
[forms]![My_subform1]![Parent_field]

then use the link parent and child fields for the 2nd subform
 
G

Guest

Hi Allen,

My problem now is the main form information do not show the selected
information until you click on one of the field. How do we make this become
automatic after the selection. The code has been enter on exit event

thanks
 
A

Allen Browne

So you want the list box to default to the first item, so that the first
record is shown?

Set the Default Value of the list box named (say) "List0" to:
[List0].[ItemData](0)

Save. Reopen the form.
 

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