Results 1 to 8 of 8
  1. #1
    ManC is offline Novice
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    22

    pass value from one form to another

    Hi,
    I need to pass value from a textbox on form1 to another textbox on form 2 on button click event.How do I do this?
    I have read about code like Form2.txtnew.text = me.text1.text for this purpose, on some other forum. But it does not work for me.Maybe I am writing the code on the wrong event.


    Please help me. Thank you.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Try

    Forms!FormName.ControlName = Me.ControlName
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ManC is offline Novice
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    22
    Still does not work.
    Can you please help me with the basics.
    My form1 has an invoice number field and i have a button to add an item. When the button is clicked it opens form2 wherein you fill more details but the invoice number from the first form is also displayed.
    The code you have mentioned goes on the _click event,right?And is there any other piece of code that goes along with this?
    I am sorry but i am pretty new at access.
    Thanks a lot for your help.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    It would go in the click event, after opening the other form, like:

    DoCmd.OpenForm "SecondFormName"
    Forms!SecondFormName.TextboxName = Me.TextboxName

    If you're still having trouble, perhaps you can post your db?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ManC is offline Novice
    Windows 7 Access 2007
    Join Date
    Mar 2010
    Posts
    22
    yay!!!!!!!!!!!Its working!!
    Thank you so much!!

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Excellent, glad we got it working.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    tahmidm is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    1
    how would you populate the textbox if the form your trying to open is closed? Thank you in advance

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You can't; you could also use OpenArgs, but either way the form needs to be opened. What are you trying to do?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Pass data from one form to another
    By Bruce in forum Forms
    Replies: 16
    Last Post: 02-25-2013, 03:59 PM
  2. Pass a form property to a procedure
    By trb5016 in forum Programming
    Replies: 2
    Last Post: 02-17-2010, 04:15 PM
  3. Pass a Parameter From a form to a Query
    By DDillesha in forum Forms
    Replies: 1
    Last Post: 10-28-2009, 12:49 PM
  4. I want to automatically pass a value to a query
    By Slategrey252 in forum Queries
    Replies: 1
    Last Post: 10-01-2009, 05:38 AM
  5. Replies: 0
    Last Post: 03-19-2006, 11:52 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums