Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a textbox in Form1 and i want to pass the value in Form2.

Ex: Textbox value is "Firstname Lastname"

and i want to pass the value of the textbox to a label in Form2.


Help please....

What I have tried:

Button on Form1
Dim str As String
str = txtValue.Value
DoCmd.Close
DoCmd.OpenForm "frmTwo", acNormal, , , , acWindowNormal, "Value=" + str
Posted
Updated 5-Apr-20 19:48pm

1 solution

Check this out: Passing parameters between forms in MS Access - Stack Overflow[^]

Quote:

VB
' Invoked by some Button on the first form '
Sub GoToSecondPage()
    DoCmd.OpenForm "MySecondPage", acNormal, , , , , txtEmployee.Value
End Sub

' Second form '
Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
        lblShowEmployeeName.Value = Me.OpenArgs
    End If
End Sub


Very important note:
The first form have to stay opened till the second form will be loaded.


A bit more information you'll find here: Passing Multiple Values to Microsoft Access Forms with the OpenArgs Parameter[^]
and here: Using Access Forms VBA: Passing Values Using OpenArgs[^]

And finally... Microsoft recommendation: Use parameters in queries, forms, and reports - Access[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900