Retrieve the value of a textbox from a different form

Solved
ismolastar Posted messages 29 Status Member -  
ismolastar Posted messages 29 Status Member -
Hello,

I would like to know what VBA code we can use to retrieve the value of a text field from a different form.
Let me explain: in form 1 I have textbox 1, then in another form 2 I have textbox 2. A button in form 1 allows me to access form 2. I would like to insert some VB code so that when I type a value in textbox 1 of form 1, it displays the same value in textbox 2 of form 2. Thank you in advance for your help.

1 answer

  1. Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   1 784
     
    Hello,

    Simply with:
    Private Sub TextBox1_Change() UserForm2.TextBox2.Value = Me.TextBox1.Value End Sub


    --
    Best regards
    Patrice
    1
    1. ismolastar Posted messages 29 Status Member
       
      Hello Patrice.
      I'm trying and I'll get back to you.
      0
    2. ismolastar Posted messages 29 Status Member
       
      Hi, it's me again,
      When I enter something in the event change, it doesn't display the text entered in form 2. There's an issue somewhere.
      0
    3. ismolastar Posted messages 29 Status Member
       
      Hi!
      Which specific event of textbox 2 should I insert the code into? Because I put it in the on change event but nothing is happening. Please help me, I'm stuck here.
      Thank you.
      0
    4. Patrice33740 Posted messages 8400 Registration date   Status Member Last intervention   1 784
       
      Just read the provided code (and your question):
      Private Sub TextBox1_Change()
      It's TextBox1 (so according to your statement, on form 1).
      0
    5. ismolastar Posted messages 29 Status Member
       
      Hello yes,
      Indeed it works. Your response really helped me find the right wording
      Here’s a summary of what I did:
      I inserted the code into the event on click procedure for those who might also find it helpful.
      DoCmd.OpenForm "button1"
      Form_1.Value = Me.date1.Value
      Form_1.Value = Me.date2.Value
      and that's it
      Thanks again Patrice33740
      0