Passing Values from continuous form to another continuous form (1 Viewer)

Nancythomas

Registered User.
Local time
Yesterday, 23:46
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
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:46
Joined
Jan 23, 2006
Messages
15,378
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.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:46
Joined
May 21, 2018
Messages
8,527
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.
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 23:46
Joined
Oct 29, 2018
Messages
21,467
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!
 

Nancythomas

Registered User.
Local time
Yesterday, 23:46
Joined
Apr 20, 2010
Messages
59
Thanks all for helping me
Here the sample. It does not list all the data into the second form.
 

Attachments

  • help.docx
    84 KB · Views: 100
  • Test1.accdb
    1.3 MB · Views: 158

Gasman

Enthusiastic Amateur
Local time
Today, 07:46
Joined
Sep 21, 2011
Messages
14,266
Why not pass the recordsource that was determined in the search form?
 

Users who are viewing this thread

Top Bottom