View Full Version : How can I pass the value of one field in a form to another field in a different form?


crhodus
03-16-2001, 12:20 PM
I have a form named “Company_Info”. On this form is a field named “Company_ID”.
I have a button on the bottom of the “Company_Info” form that opens another form named “Project_Form“. This form allows the user to enter in project information. It also contains a field that is named “Company_ID”.

The “Company_Info” form stores its data in a table called “Customer”, and the “Project_Form” form stores its data in a table called “Project

How can I have the “Company_ID” field value from the “Company_Info” table automatically pass its vaue to the “Company_ID” field that is in the “Project_Form” when that company’s “Project_Form” is filled out for the first time?

zunan
03-16-2001, 06:10 PM
If the cmd button on the Company_Info form opens the Project_Form in add mode, set the default value of the CompanyID field to
"Forms!Company_Info!Company_ID". The only requirement for this to work is that the Company_Info form needs to be open to get the default value from.
If you want the Project_Form to open in edit mode and list all of the company's projects add a "where" condition to the code behind the command button that opens the Project_Form. "DoCmd.OpenForm "Project_Form","Company_ID &" = Forms!Company_Info!CompanyID

crhodus
03-19-2001, 05:40 AM
Thanks! You've been a great help.