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

Copy data from one form to another 1

Status
Not open for further replies.

mphayesuk

IS-IT--Management
Apr 22, 2003
46
GB
I have a form that users enter data on.. when they click on a button I want a different form to appear and to copy the data from field1 on form1 to field 1 on form 2.

Thanks
 
If Form1 holds the data, then on Form2:

For unbound fields(data not going into a table), in the ControlSource put:

=MyFormName!MyControlName

If you want to store the data in a Form2 table, then your ControlSource will be the field name on Form2, and use the same line above in the DefaultValue property of the control.

Other methods are also possible, but I think this is the easiest for you to understand.

HTH,
Mike Dorthick
 
You may also take a look at OpenArgs

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks MD5150... but I have tried that and all I get in the form2 textfield is #Name?.. but I am sure that I have referenced all the field properly... any other ideas.

Thanks
 
Post your reference syntax.

Also, tell us about Form-2 and the transfered data.

For example:

1) Is Form-2 bound, or unbound? Meaning, does it use an underlying table or query for it's RecordSource? If yes, then it's a bound form.

2) Are you're storing this transfered data in Form-2's bound table, or is it just header information used for display only?

Mike Dorthick

 
Have a look at
Thread702-864326

Hope this helps
Hymn
 
Form 2 is bound to a table and yes the data transfered from form1 to form2 will need to be stored in table2.

Thanks
 
There's many ways.

Simple referencing between forms and controls:
You can have Form2 open to a new record and use the control's DefaultValue property to reference the Form1 fields. Or OnOpen of Form2, you can run code to see if Form1 is open, and if so, get the values. Or even from the 'open form2' button located on Form1, you can throw the values over to Form2 after it opens. Or you can put a "Get Data" button on Form2 and grab the Form1 values from there. All depends on how you want things flow.

You can open a form using where conditions as shown in the following link:


Or this link where AceMan details OpenArgs regarding your same question:


Any of this should get you there.

HTH,
Mike Dorthick
 
How are ya mphayesuk . . . . .

I believe you want to transfer to a [blue]new record[/blue] in the [blue]opened form[/blue], and since you have [purple]a number of fields you want to pass[/purple], try this:

[blue]In your code for the buttion on the independent form[/blue], make sure you open the dependent to a new record. Code should include something like the following (you substitute proper names in [purple]purple[/purple]):
Code:
[blue]   DoCmd.OpenForm "[purple][b]FormName[/b][/purple]", acNormal, , , acFormAdd[/blue]
Then in the [blue]On Load[/blue] event of the [blue]dependent form[/blue] copy/paste the following:
Code:
[blue]   Dim frm As Form
   
   Set frm = Forms![purple][b]IndependentFormName[/b][/purple]
   
   Me![purple][b]ControlName[/b][/purple] = frm![purple][b]ControlName[/b][/purple]
                       [green][b]'[/b][/green]
                       [green][b]'[/b][/green]                                   
   Me![purple][b]ControlName[/b][/purple] = frm![purple][b]ControlName[/b][/purple]
   
   DoCmd.RunCommand acCmdSaveRecord

   Set frm = Nothing[/blue]


Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top