Form Update

G

Guest

Hi, I'm trying to set up a form and subform based on two tables with DEPTID
as primary key in both. I'm using an AUTONUMBER field in main table to
increment each time a new record is added.

Problem is when I populate the DEPTID field in the main form using a COMBO
BOx, the DEPTID field in the subform does not populate. Is there a way to
autopopulate the DEPTID field in the subform from the main form, or do I just
need to have it typed in?

Thanks in advance.

KP
 
N

Nick Coe \(UK\)

You shouldn't really have the primary key in both tables as
the link.

Without knowing exactly what your two tables are I can only
do a bit of guessing:

Parent table (main form) primary key should really be the
Autonumber. Then create a Long integer field in the child
table (sub form) to be the foreign key and hold the value
from the autonumber as rows are created. In the
relationship manager add the two tables to the view and
create a one to many relationship between them with the
parent being the one side and the child the many. Link on
the autonumber to the long integer field - Primary key to
foreign key. When you create the relationship set cascade
updates but I don't usually set cascade deletes.

In the subform control on the form now set the parent and
child field link to the primary and foreign key
respectively.

DEPTID really only needs to appear once, without knowing
what your table design is I can't say exactly where.

That ought to get you started I reckon.
 

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