How to auto populate a subform based on pk

  • Thread starter Jenny Lee via AccessMonster.com
  • Start date
J

Jenny Lee via AccessMonster.com

I am having so much hassle!! I have a main form with a subform. I dont want
data entry into the subform it is just used to look up info from another
subform. I cant seem to achieve this.The ID field is a combo box that looks
up ID Code That seems to work O.K but when I select the ID the other fields
do not populate based on the ID they are just blank???? Please Help!!!! I
know it cant be that hard.
 
J

Jeff Boyce

Jenny

First things first ... does Access know how the main form and sub-form are
related? The subform control on the main form as Parent and Child
Properties so it can stay coordinated. What do you have in these?

Next, the subform, by itself, in design mode, needs to NOT be set to Data
Entry = Yes. Otherwise, you'll only be able to add new records.

Finally, the subform needs to be based on a set of data which has a field
that corresponds (as a foreign key) to the "parent" record in the main form.
Can you confirm that you have records showing up in the subform (by itself,
not inside the mainform)?
 
J

Jeff Boyce

Uhhhm... so this is a puzzle, then. If everything is "as it should be", but
the subform returns no records, then there aren't any subform records to
return <G!>.

Let me try again...

A typical mainform/subform design would have:
a combo box in the main form's Header section, to allow selection of a
record in the main form. This would be an unbound combo box, based on the
available mainform records. This combo box would have an AfterUpdate event
that requeries or (re-)filters the main form.
a main form that displays main-table record information, including the
record ID of the main-table holding the information relevant to the main
form.
a subform control, bound to a different table, said table having its own
ID, plus a foreign key that points to the mainform table's primary key.
said subform having Parent and Child properties filled in, using the
common ID (primary key in main form, foreign key in subform)
actual records in the "child" table related (via foreign key) to records
in the "parent" table.

If your situation has all of these, I'm at a loss to explain why your design
isn't working.
 

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