How synchronize data from 2 forms ?

  • Thread starter Thread starter David
  • Start date Start date
D

David

I have a form that adds a row to a table with an
autonumber key. On this form is a button to go to another
form. This second form adds data to another table with an
autonumber key. The record added by the second form is
related to the record added by the first form via the
first form record's autonumber key.

Problem 1: How do I get the autonumber key for the second
form when the record to be added by the first form has not
been added yet.
Problem 2: What do I do if the second form adds a record,
then the user cancels out and does not add the record from
the first form?

How should I handle this? There is no room on the form for
all of the data, thats why I split it into 2 forms.
 
David said:
I have a form that adds a row to a table with an
autonumber key. On this form is a button to go to another
form. This second form adds data to another table with an
autonumber key. The record added by the second form is
related to the record added by the first form via the
first form record's autonumber key.

Problem 1: How do I get the autonumber key for the second
form when the record to be added by the first form has not
been added yet.
Problem 2: What do I do if the second form adds a record,
then the user cancels out and does not add the record from
the first form?

How should I handle this? There is no room on the form for
all of the data, thats why I split it into 2 forms.

You are not asking for this but, why do you need two tables? If there is a
one-to-one relationship between the first table and the second, in this case
it should just be one table.

On the other hand, if there is a one-to-many ( i.e. for every one record in
the first table , there can be many records in the second table)
relationship between the first table and the second, then you should not be
using an autonumber format alone as a key to the second table.

The first table has one key, an autonumber format, let's call it FIndex.

The second table should have two fields as its key , the first called FIndex
of type long integer, the second called SIndex of type autonumber. Link the
two tables together using the Tools/Relationships menu.

In either case , you should only use one form divided into pages. Put a
"Page Break" icon which you get from the toolbox at the end of where you
want the first page to be, and do the same for the second page, third page,
etc. Put a button on the form footer called "Page 2" and on the OnClick
event I put the code " Me.GoToPage 2 ". Likewise a button on the form footer
called "Page 1" and on the OnClick event I put the code " Me.GoToPage 1 ",
do this for as many pages as you need.


Jack
 
Back
Top