Relationships between forms

  • Thread starter Thread starter craig kelly
  • Start date Start date
C

craig kelly

When I create a new record in one form, I want it to
create a new record in another form, both forms are based
on the same query and contain the 'PRIMARY KEY' which is
the field 'Run Number'.

i.e. Form A and Form B are based on the same record
source. The records held in each form are linked by a
common 'Run Number', so 'Run Number' in Form A should
relate to the same 'Run Number' in Form B.

At the moment when I create a new record in Form A it
does not automatically create one in Form B even though
they both contain the field 'Run Number' which is the
PRIMARY KEY, how do I do this?

If I open Form B using an Open Form macro on a command
button from Form A, it opens it at record 1 instead of at
the same record number which I was viewing in Form A, how
do I get it to Open displaying the same record?


Any help would be appreciated as this is driving me up
the wall!

Thank you

Craig.
 
When I create a new record in one form, I want it to
create a new record in another form, both forms are based
on the same query and contain the 'PRIMARY KEY' which is
the field 'Run Number'.

Bear in mind that a Form is JUST A WINDOW. You don't store records in
Forms - instead, you use Forms as a tool to store data in a Table. The
data exists in the table, and *only* in the table.
i.e. Form A and Form B are based on the same record
source. The records held in each form are linked by a
common 'Run Number', so 'Run Number' in Form A should
relate to the same 'Run Number' in Form B.

Well, no. Actually that's not what's happening. If the forms are based
on the same recordsource, then it's like having two windows side by
side in your house, looking at the same scene. What's different is
that the window is "lazy" - it doesn't update what you see through it
automatically.

What you can do (if you really want this rather unusual arrangement)
is to Requery Form B in the AfterUpdate event of Form A.
At the moment when I create a new record in Form A it
does not automatically create one in Form B even though
they both contain the field 'Run Number' which is the
PRIMARY KEY, how do I do this?

If I open Form B using an Open Form macro on a command
button from Form A, it opens it at record 1 instead of at
the same record number which I was viewing in Form A, how
do I get it to Open displaying the same record?

You can use the Command Button wizard to create some VBA code to open
Form B; one of the optional arguments to the OpenForm call is a
Filter, and another is a WhereCondition. Either one will let you open
the form showing just the selected record - the filter will allow the
user to turn off filtering and see all records.

Use the command button wizard, and choose the option "Open this form
and show specific data". If that doesn't get you what you want, post
back; it's not hard to set this up.
 
Back
Top