Pasting into Access from Excel - Non-numeric entries don't get through

Israel Lopez picture Israel Lopez · Apr 23, 2014 · Viewed 20k times · Source

Every once and awhile a user will complain about my Access application losing fields. I've found out that they are right. Access in certain situations will simply drop accepting data from a copy and paste operation for a certain field, consistently.

It is almost as if Access thinks that the pasted data is only numeric data, then onces it sees Alpha it attempts to cast to a number, fails then ignores it.

The image below is not the custom application but a new Access file, where I just copy and paste the Excel data raw. I've looked at the raw clipboard data using http://www.peterbuettner.de/develop/tools/clipview/ but I do not see any obvious issues or format issues.

Thoughts?

Test Application and Data

Answer

Yawar picture Yawar · Apr 24, 2014

Do a 'paste special' operation and paste as plain text. For ease of use, I recommend pinning the 'paste special' button to the Quick Access toolbar.

Sometimes Access gets confused when you let it guess what you're pasting. Pasting as plain text is the best way to force it to work.

Edit

Example Code for Right Click Menu

Public Function CreateGeneralClipBoardMenu()
    On Error Resume Next
    CommandBars("GeneralClipboardMenu").Delete

    Dim cmb As Office.CommandBar

    Set cmb = CommandBars.Add("GeneralClipboardMenu", msoBarPopup, False, False)

        With cmb
            .Controls.Add msoControlButton, 21, , , True  ' Cut
            .Controls.Add msoControlButton, 19, , , True  ' Copy
            .Controls.Add msoControlButton, 755, , , True  ' Paste Special
        End With

    Set cmb = Nothing
End Function

The ID# 755 is a magic number for Paste Special, and I found it on this list: http://support.microsoft.com/kb/213552

Where to set it in Access 2013. Access Options - Current Database - Shortcut Ribbon Bar

Access Options - Current Database - Shortcut Ribbon Bar