Passing Values from continuous form to another continuous form

Nancythomas

Registered User.
Local time
Yesterday, 19:56
Joined
Apr 20, 2010
Messages
59
I have two forms (FORM_B) AND a sub-form (FORM_A)


FORM_B - is a search form that provides the results as a continuous form (Example)
EmpNo Surname FirstName Department
123 Smith John Sales
423 Harry Jim Sales
563 Tom Eric Sales


I would like to pass the above information by a click of a button in FORM_B to a subform FORM_A.


I want to load the above information from FORM_B to a subform FORM_A


I can pass a single row but I am unable to load all the three rows automatically by a button click.


My Event script is as follows:


Private Sub cmdOpenFORM_A_Click()
Me.Refresh

Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "FORM_A"


stLinkCriteria = "[EmpNo]=" & Me![EmpNo]

[Forms]![frmEmails]![FORM_A]![EmpNo] = Me![EmpNo]
[Forms]![frmEmails]![FORM_A]![EmpNo] ![txtFirstName] = Me![FirstName]
[Forms]![frmEmails]![FORM_A]![EmpNo] ![txtSurname] = Me![Surname]
[Forms]![frmEmails]![FORM_A]![EmpNo] ![txtDepartment] = Me![DivDescription]

DoCmd.Close

End Sub



-----
My FORM_A has the same fields as a continuous form:
EmpNo Surname FirstName Department


Please help
 
Can you describe how FormA and the subform relate in plain English?
And perhaps an example (or 2) of the form and subform populated with values like you describe. Just trying to get an idea of what you are trying to achieve.
Good luck.
 
I also have questions about this design. Copying values from one table to another is usually a symptom of poor design. But if for some reason this table structure makes sense then I would use the recordsets of each. Loop form b records and add them to the recordset of subform A. This is totally untested, off the top of my head.

Code:
Dim rsB as dao.recordset
Dim rsA as dao.recordset
set rsB = me.recordset
set rsA = Forms!frmEmails.FORM_A.Form   'Assumes subform control is called Form_A 

do while not rsB.EOF
  rsA.addNew
    'Assumes field names are the same
    rsA!EmpNo = rsB!EmpNo
    rsA!FirstName = rsB!FirstName
    rsA!Surname = rsB!surname 
    rsA!DivDescription = RsB!DivDescription    
  rsA.Update 
  rsB.moveNext
Loop

may need a requery to show the additions.
 
Hi Nancy. Continuous forms typically mean you're displaying records from a table. As such, you wouldn't really pass rows to the form; rather, you would pass it to the underlying table. However, we all try to avoid storing duplicate data in multiple tables. So, knowing a little bit more details about your setup and your goals would help us give you an appropriate approach. Cheers!
 
Thanks all for helping me
Here the sample. It does not list all the data into the second form.
 

Attachments

Why not pass the recordsource that was determined in the search form?
 

Users who are viewing this thread

Back
Top Bottom