referencing data on a different form

M

mark kubicki

When adding a record at a form to a table which requires some data from
a second (open) form;

what's the best way of referencing the field values?

any suggestions would be a great help, thanks in advance,
mark
 
J

John W. Vinson

When adding a record at a form to a table which requires some data from
a second (open) form;

what's the best way of referencing the field values?

any suggestions would be a great help, thanks in advance,
mark

Whoa here.

It sounds like you may be on shaky ground here: it seems that you're
proposing to store data redundantly, assuming that data is stored in
Forms rather than in tables, assuming that the other form will always
be positioned at the right record...

Could you step back and say what data you want copied, why, and how
you can be assured that you'll be getting the right data?

John W. Vinson [MVP]
 
M

mark kubicki

- the first form contains information about an item (manufacturer, catalogue
no...)
- the second form is essentially a table of cost history of the item
(11/12/2005 - $2.00, 11/12/2006 - $5.50, 11/12/2007 - $5.00...); - it is
opened by a command button on the first form and filtered for records that
match the manufacturer and catalogue no.
- each new record for the table that is the second form's data source
requires the related fields for manufacturer, and catalogue no. (as well as
cost, date... which the user enters)

I want, on the second form, to be able to add additional records to the
table, and want to do so without the user having to enter the manufacturer
and catalogue no (it is always the same as on the first form, and should be
gotten automatically)
 
J

John W. Vinson

- the first form contains information about an item (manufacturer, catalogue
no...)
- the second form is essentially a table of cost history of the item
(11/12/2005 - $2.00, 11/12/2006 - $5.50, 11/12/2007 - $5.00...); - it is
opened by a command button on the first form and filtered for records that
match the manufacturer and catalogue no.
- each new record for the table that is the second form's data source
requires the related fields for manufacturer, and catalogue no. (as well as
cost, date... which the user enters)

I want, on the second form, to be able to add additional records to the
table, and want to do so without the user having to enter the manufacturer
and catalogue no (it is always the same as on the first form, and should be
gotten automatically)

By far the simplest way to do this is to make the second form a
Subform of the first one, using the item's unique key - which might be
the Manufacturer and the Catalogue Number in conjunction - as the
subform's Master Link Field and Child Link Field. If you're short of
screen real estate, you can use a Tab Control and put the subform on a
tab page.

If you have a real need to use a separate form, you'll need some VBA
code. Open the form using a WhereCondition (rather than a filter)
selecting the manufacturer and catalogue number; and ALSO pass those
values (delimited appropriately) in the OpenArgs parameter of the
OpenForm method. Then in the second form's Open event set the
DefaultValue property of the controls to the values passed from the
first form.

John W. Vinson [MVP]
 
Top