Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Access 97 forms and parameters

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I have a form that has a combo box and a button beside the combo box. If the combo box does not contain the needed data then the user would push the button and a new form will pop up. This new form is where the user will added the new combo box item and any additional information. The form is tied to a table (EX:vendor) as well as the combo box. The button serves as a way to added items to the combo box. The problem I am having is:

How do you send the newly created item to the previous form?
Form1 has a combo box and a button. Then user pushes the button and it opens form2. The user adds a new vendor to form2 when the user closes form2 then I want the newly added vendor to fill in the combo box on form1.
 
I think my question may be confusing. How do I make the data from form2 update the combo box on form1. So when the user adds to form1 it also inputs the new vendor into the current record on form1.
 
Your going to have to individually place the data into the appropriate controls on the first form. Remember you can refer to any control on your form in VBA using...

[Forms]![<name of form>]![<name of control>]

Where the name of your form and control are in the name property of that item. So to assign lets say, &quot;Xibit Sprockets&quot; to the text box for company name that has the name &quot;txtCompany&quot;, which exists on a form by the name of &quot;frmOrder&quot; then use:

[Forms]![frmOrder]![txtCompany] = &quot;Xibit Sprockets&quot;

Now to pull the information that the user entered instead of placing hte Xibit Sprockets directly into the code you can again refer to the control. Assuming the second form is called &quot;frmCompany&quot;, and the box they enter the company name into is called, &quot;txtCompanyName&quot; then type:

[Forms]![frmOrder]![txtCompany] = [Forms]![frmCompany]!
[txtCompanyName]

If you have a button that closes the second form then this information could be placed into that button so that it executes when the user closes the second form. If you are just letting them close the second form like any other window (by clicking the X) then you can place this code into the On_Unload event of the second form. There are many ways to accomplish what you are trying to do, but I think this is the easiest one to explain completely.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top