How do I put a field into text edit mode on a Access form using VBA?

Posted on 2012-08-29
Last Modified: 2012-08-29
I'm actually trying to allow a button press to copy a text from the textbox on that line and paste it into the txtPaste textbox in the header of the form. I have managed to get that working but I want to be able to paste many different things and have them fill up the txtPaste textbox as they keep clicking different buttons.

My thought was to put the textbox into text edit mode by pressing the F2 key so I added a sendkeys line to my vba but it didn't work for some reason. It just keeps pasting over the existing text in the txtPaste box.

Here is my current code;

Private Sub cmdCopy_Click()

DoCmd.GoToControl "KeyPress"

DoCmd.RunCommand acCmdCopy

DoCmd.GoToControl "txtPasteCell"

SendKeys "{F2}"

DoCmd.RunCommand acCmdPaste

End Sub

Thanks for the help!
Question by:SeyerIT
    LVL 61

    Accepted Solution

    Try this to position the cursor at the end of the text before pasting the data:

                me.txtPasteCell.SelStart = len(Me.txtPasteCell & "")
                Me.txtPasteCell.SelLength = 0

    Open in new window

    LVL 2

    Author Closing Comment

    Perfect, Thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
    Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now