Pass value from popup form to subform via the main form (1 Viewer)

Nancythomas

Registered User.
Local time
Yesterday, 16:55
Joined
Apr 20, 2010
Messages
59
I have designed a database with a main form and multiple subforms linked to the main form.

The main form is [Mainformstock_frml] and the [Subformstaff_frm]

The value gets passed from a popup form correctly but the problem is it directly open the subform [Subformstaff_frm] and passes the value.

I would like to pass the value from the popup form on to the form that is already opened.

Here is the script can you please advise what is incorrect and how can I get this to work.....


Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "Subformstaff_frm" ' This may be incorrect.........

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

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.EMPNO
Forms![Mainformstock_frml]![Subformstaff_frm]![EMPNO] = Me![EMPNO]
Forms![Mainformstock_frm]![Subformstaff_frm]![txtFirstName] = Me![Firstname]
Forms![Mainformstock_frm]![Subformstaff_frm]![txtSurname] = Me![Surname]

End Sub

Thanks
 

JHB

Have been here a while
Local time
Today, 01:55
Joined
Jun 17, 2012
Messages
7,732
..
I would like to pass the value from the popup form on to the form that is already opened.

Here is the script can you please advise what is incorrect and how can I get this to work.....


Dim stDocName As String
Dim stLinkCriteria As String


stDocName = "Subformstaff_frm" ' This may be incorrect.........

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

DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.EMPNO
Forms![Mainformstock_frml]![Subformstaff_frm]![EMPNO] = Me![EMPNO]
Forms![Mainformstock_frm]![Subformstaff_frm]![txtFirstName] = Me![Firstname]
Forms![Mainformstock_frm]![Subformstaff_frm]![txtSurname] = Me![Surname]

End Sub

Thanks
Then delete the line because it opens the form Subformstaff_frm.
Code:
DoCmd.OpenForm stDocName, , , stLinkCriteria, , , Me.EMPNO
 

Nancythomas

Registered User.
Local time
Yesterday, 16:55
Joined
Apr 20, 2010
Messages
59
JHB

Yeppy Yahoo.....:D
Thank you very very much.
I was trying to get this work for the last three days.
Appreciate all your help.

Thanks again
 

JHB

Have been here a while
Local time
Today, 01:55
Joined
Jun 17, 2012
Messages
7,732
JHB

Yeppy Yahoo.....:D
Thank you very very much.
I was trying to get this work for the last three days.
Appreciate all your help.

Thanks again
You're welcome, good luck.
 

Users who are viewing this thread

Top Bottom