Results 1 to 4 of 4
  1. #1
    Kev86 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2022
    Posts
    68

    Open new form and copy and paste from one text box to another

    I have a form with an unbound text box that is used to get data for multiple sub forms. Due to the limitations of the forms height and width I really need a second form but rather than the user having to open the second form and then having to type their name in the search box again i want the button to do it all for them. I have code on the button to easily open a new form from within a current form "DoCmd.OpenForm "SplashPageDesignerPg2""



    I can easily move text from one unbound text box to another within the same form using "Me.[Text146] = Me.[Enter Designer Name]". However trying to copy and paste the text from one unbound text form to another on a completely different form is where i am getting stuck.

    I have tried "SplashPageDesignerPg2!Me.[Enter Designer Name] = Me.[Enter Designer Name]" but i get an error. The form open is called SplashPageDesignerPg1, the button then opens form SplashPageDesignerPg2, the unbound text fields on both forms are called 'Enter Designer Name' i am hoping that won't cause an issue being the same in both forms?

    I want whatever the user has added to the unbound text field of SplashPageDesignerPg1 to then copy and paste into the same field of the SplashPageDesignerPg2 form after it's opened.

    Any help with this would be much appreciated.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771
    Could use OpenArgs argument of OpenForm.

    DoCmd.OpenForm "SplashPageDesignerPg2", , , , , , Me.[Enter Designer Name]

    Then code in other form, probably Open event.

    Me.[Enter Designer Name] = Me.OpenArgs

    Or maybe use expression in textbox and no VBA: =[OpenArgs]
    Depends if this form is also called from elsewhere.

    Otherwise:
    Forms!
    SplashPageDesignerPg2.[Enter Designer Name] = Me.[Enter Designer Name]


    You would have fewer headaches if you did not use spaces in naming convention.


    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Kev86 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2022
    Posts
    68
    June7,

    Thank you, I used the second piece of code you provided and that worked perfectly.

    Forms!SplashPageDesignerPg2.[Enter Designer Name] = Me.[Enter Designer Name]

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    Code:
    Forms!SplashPageDesignerPg2.[Enter Designer Name].DefaultValue = Me.[Enter Designer Name]
    You might also want to set the control as a default value rather than a straight value. If a user should open the form by mistake they can just close it rather than having to undo it. When you set a controls value by code it will trigger a new record.
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

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

Similar Threads

  1. Replies: 3
    Last Post: 08-01-2022, 04:13 AM
  2. Replies: 1
    Last Post: 05-18-2017, 01:36 PM
  3. Replies: 1
    Last Post: 05-16-2016, 05:58 AM
  4. Replies: 3
    Last Post: 03-19-2015, 02:11 PM
  5. Replies: 2
    Last Post: 10-23-2014, 08:19 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