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

Moving data from one form to another

Status
Not open for further replies.

Remel

Programmer
Oct 14, 2000
4
US
Any help is greatly appreciated. I have two forms bound to two corresponding (and different) tables (Form A, Form B, Table A, Table B).

Form B is opened as a pop-up from a button on form A. I would like for a particular field (ClientID) of the current record in form A to be "copied" to a corresponding field in form B. the user will then type info in other fields in Form B and save the data to Table B. Can anyone help me with this "copy"? Thanks in advance [sig][/sig]
 
Hi Remel,

Are there any restrictions on the other fields in table b, like required set etc, there are numerous ways to do this.

create record sets based on the tables and loop through the first adding to the second. may need to use the refresh method so the updated records appear on the form.

or add append sql statement to the first form under an "Add" button and append the records,

also i take it both table a and table b have parent tables if so you will need to add the parent key first ofcourse. or open the pop up adding this when it opens (not sure of the entire situation)

you could also add tag (yes/no) field to table a and use this to add "selected" entries only.

hth [sig]<p>Robert Dwyer<br><a href=mailto:rdwyer@orion-online.com.au>rdwyer@orion-online.com.au</a><br>[/sig]
 
I have been trying to find a solution to this as well. Would you mind being a little less vague? THANKS! [sig][/sig]
 
ALSO!
I put my question out in another forum, and this was the code that I was given to sort it all out. I have one table that is linked to some other ones by a customer Id. I want the same thing to happen. When you enter info into the first form, and then push the button to open the next one, there will either be: A. The related reccord because you already entered it, or B. a reccord with the related field all nicely filled in for you so you don't have to do it a million times. Maybe this will help you. (I can't seem to get it to work for me, but that's probably because I have very little VBA knowledge. Either that, or I'm a dolt.)

:

Dim StrLinkCriteria As String 'Declare the variable StrLinkCriteria
Dim stDocName As String 'Declare the variable stDocName
stDocName = &quot;Section B&quot; 'Define stDocName

'If there is already a record corresponding to the ApplicantID in Section B
'Open the form with that record
If DLookup(&quot;[ApplicantID]&quot;, &quot;[Section B]&quot;, &quot;[ApplicantID]=&quot; & Forms![SECTION A]![ApplicantID]) Then
'Define StrLinkCriteria, open the form in edit mode and requery the source for the form
StrLinkCriteria = &quot;[ApplicantID] = Forms![Section A]![ApplicantID]&quot;
DoCmd.OpenForm stDocName, , , StrLinkCriteria
DoCmd.Requery
'Otherwise open the form in add mode and set the OpenArgs value to the ApplicantID
Else
DoCmd.RunCommand acCmdSaveRecord
DoCmd.OpenForm stDocName, , , , acAdd, , Me!ApplicantID

You just have to substitute your own table and form names.
What this does though is it first copies the applicantID to opening arguments then it looks to see whether a record exists and if not will create the new record with the same applicantID (which was copied to opening arguments)

HTH
Kate [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top