Form Field issue - Please, any advice is helpful

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have linked to forms together using a primary key. What I would like to
have happen follows.

On the main Form I have the primary key (Project_no), this key appears in
almost all of my tables. I have a button on the main form that opens up a
subform that allows you add additonal information for the project. The
Subform has the primary key (Project_no) listed as well. What I want to do
is, when I click the button to launch the subform, can I have the Project_no
primary key autopopulate in the subform so the entry person doesn't have to
reenter this information ?

Just had this project dumped on me and not very familiar with Access XP, was
familiar with 2.0 but that's the extent of my Access knowledge.

Thank You for any assistance that you can offer.

Mike Bayne
 
There's a wizard (at least in A2K) that allows you to do this... but there's
a problem with it.

It sets up the code something like....

docmd.openform "FormBasedOnChildTable"
forms!FormBasedOnChildTable.filter="[Project_no]="+me.project_no
forms!FormBasedOnChildTable.filteron=true

which works fine for displaying existing child records, but doesn't
automatically populate the key field on the child table for new records
entered on FormBasedOnChildTable. To fix that, add...

forms!FormBasedOnChildTable!ctlProject_no.defaultvalue=me.project_no

Last thing... if the first form is on a new record then that will cause an
error as there won't be a Project_no (if you're using an AutoNumber). You
can check for...

if me.newrecord then

....to stop the FormBasedOnChildTable opening in that situation.
 
Back
Top