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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving Data across multiple forms

Status
Not open for further replies.

mpnorris

IS-IT--Management
Dec 31, 2002
66
US
I have created a form where I choose a name from a dropdown list. The information on that person is transfered over to the next form when I hit the "Continue" Button. I can see the data on the next screen, but I want to click another button and have the information brought from the first form onto the third form.

Does anyone have any ideas. I have chosen to change my form order around and now I need to keep the data from form to form.

Any help would be greatly appreciated.

 
Do you keep your first form open? If so, then when the third one is open refer back to the specific controls on the first form. For example: a control on form1 is txtName and I want to bring it to form3 txtname. I would put this "=[Forms]![Form1]![txtName]" in the control sources of txtName on form3

Hope this helps. If you need to close form 1 then create public variables and load the information into those public variables and then close form1 so you can refer to the public variables in then form3.
 
Hi,

You could try setting the controls on the third form to the controls of the first form with your continue button:

Ex:

DoCmd.OpenForm "ThirdForm"
Forms!ThirdForm.TextBoxName = Forms!FirstForm.TextBoxName
Etc...

* This should work as long as the first form stays open. If you are going to close the form than you will need to query the recordset of the first form and pass the values via a query or function.

HTH,

jbehrne

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Note - sunshine19's post will work (but the values of the form will always be set by the first form - so if form1 is not open then form3 will show errors). So if you are going to reuse the third form and have it accept values from a user (like having the form page through a recordset) then my post will work because it only displays the records from form1 to form3 in the code's instance...

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Thanks for the info. It worked. I am planning on keeping the original form open so it was easzy to bring the data over.

The next question I have is:

I have all of the data as text in the fields on the third form. When I click the "Add Record" button I need two of the fields that I just populated to be put into a record on the database.

I tried to point the new field to the field in the database as well and it didn't work.

This is what I did for the txtDept_ID field:

=[Forms]![frmHomePage]![txtDeptID] & [Mispost_Tran]![Dept_ID]

This did not work. The field didn't even populate when the form was open. I received an error.

Any help would be greatly appreciated. Thanks again for you quick response.

 
Hmmm..., not sure what you are trying to do.Are you trying to add the values to a table - if so have you tried using a sql statement to add the values to the table? If the values that your are trying to insert into a table are going to new records your command would look something like this:

DoCmd.SetWarnings False

DoCmd.RunSQL "INSERT INTO TableName ( [Field1], [Field2] )
VALUES Me!TextBox1, Me!TextBox2"

DoCmd.SetWarnings True

If you are updating a recordset it would look something like this:

DoCmd.SetWarnings False

DoCmd.RunSQL "UPDATE TableName SET TableName.Field = [Forms]![FormName]![TextBox] WHERE TableName.UniqueField = [Forms]![FormName]![UniqueValueTextBox]"

DoCmd.SetWarnings True

- If you want to combine two fields into one do it in code first then insert it into your table:

I.E.
Dim Val1

Val1 = [Forms]![frmHomePage]![txtDeptID] & [Mispost_Tran]![Dept_ID]

- or you could set a field on your form equal to this value (using the form's "On current" event:

Me!TextBox = Val1


HTH,

jbehrne

If at first you don't succeed, call in an airstrike. - Murphy's Laws of Combat Operations
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top