Search code examples
formsms-accesstextboxvba

Access: User entered Value to Label


I'm trying to figure out how to take a value entered inForm1 from a user, and then take that value and turn it into a label in Form2. So for example, if the user enters "Apple" in Textbox1 in Form1, how would I grab that value and enter it into Label1 in Form2.

I know code to change a label is

Private Sub Command56_Click()
    Label1.Caption = "Something else"
End Sub

but I'm not sure how to get a user entered value from another form.


Solution

  • That could be:

    Private Sub Command56_Click()
        Label1.Caption = Nz(Forms("Form1").Textbox1.Value)
    End Sub
    

    Nz prevents an error should Textbox1 be empty (Null).