How to reuse in a subform an information of the main form?

A

arnicot

Hi,
I have a main form (father form) with several sub forms (son forms).
To make a select, inside one of the sub forms, I need an ID which is on
the main form.
How to get it?
Is it possible to store the ID in a kind of common place, available for
any sub form?
Thanks for your help.
 
J

John Vinson

Hi,
I have a main form (father form) with several sub forms (son forms).
To make a select, inside one of the sub forms, I need an ID which is on
the main form.
How to get it?
Is it possible to store the ID in a kind of common place, available for
any sub form?
Thanks for your help.

What will you do with it when it's selected? How are you selecting it
- in code, in a query, to display on the subform?

Typically you would use the unique ID of the mainform as the "Master
Link Field" of the subform, and the related field in the subform's
recordsource table or query as the Child Link Field. Do you want to do
this, or something else?

John W. Vinson[MVP]
 
A

arnicot

John Vinson a écrit :
What will you do with it when it's selected? How are you selecting it
- in code, in a query, to display on the subform?

Typically you would use the unique ID of the mainform as the "Master
Link Field" of the subform, and the related field in the subform's
recordsource table or query as the Child Link Field. Do you want to do
this, or something else?

John W. Vinson[MVP]
The application's goal is to manage a book library.
This is the part of the schema with whom I have a problem:

Entities:
1°- A table (tab_book) to store the main information of each book
2°- A table (tab_stock) to store the quantity on stock within the
different storage locations.
3°- A table (tab_name_sto) to give the name and description of each
storage location.
4°- A table (tab_mvt) to store all the stock movements: qty in and out.

Relations:
1 to N between tab_book and tab_stock using book_number which is the
primary key of tab_book
1 to N between tab_name_sto and tab_stock using id_name_sto which is the
primary key of tab_name_sto
1 to N between tab_stock and tab_mvt using id_stock which is the primary
key of tab_stock

---------
|-- tab_mvt
| ---------
|
------------ ---------- |
tab_name_sto ------- tab_stock ----|
------------ ---------- | ---------
|-- tab_book
---------

Forms:
1°- A main form to show the book information: title, price, etc.
2°- A sub form based on tab_stock to show the different locations where
the book is stored (in this sub form I use a SELECT to retrieve the name
of the stock through tab_name_sto since the id_number exists in tab_stock)
3°- From this sub form, I'd like to use a SELECT to get the relevant
movements through tab_mvt when we click on a stock name.
But, to program the WHERE clause of my SELECT I need the book_number
which is part of the main form, and I can't get it. That's my problem.
(when I force the book_number, just for test purpose, it works). That's
why I'd like to know if it's possible to store the book_number somewhere
to make it available for any subform.
Hope it's clearer for you now.
 
Top