Results 1 to 8 of 8
  1. #1
    dickn is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Victoria BC, Canada
    Posts
    15

    docmd.runcommand accmdpaste - data is NULL

    Hi,

    I used the acCmdPaste function to fill in a text field on a form but the data is always 'null'.
    I'm trying to read from the ClipBoard and the data has been copied there from Notebook.
    If I manually paste to the text field it is there. I don't understand why acCmdPaste is not
    working as advertised in this case. I have done Me.Datafield.Setfocus and all that but no joy.



    Anyone?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I just tested acCmdPaste and it worked. What event do you have the code in?

    How is the clipboard filled - ctrl+C?
    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
    dickn is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Victoria BC, Canada
    Posts
    15
    Hi,

    Well that is encouraging (that it worked for you).

    My code is in a Command_Click event. I've also tried it in a Label_Click event.
    Same problem. The Label is in the Details Header, the Command is in Details.
    There are no subforms. I load the Clipboard from Notebook using right-click Paste.
    I start with ctrl+A to select all. Maybe I'll try ctrl+C and see what I get.

    When I Paste directly to the text field (which is unbound) using right-click Paste
    I have to hit Enter to process the data because the Text_AfterUpdate does not fire
    when you paste. Too bad. I'll bet it's something simple and/or stooopid.

  4. #4
    dickn is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Victoria BC, Canada
    Posts
    15
    I tried the ctrl+V. No change. But I did discover that the acCmdPaste is not reading 'nulls'
    from the Clipboard. If I Paste the data to the Text field and then click the Command button
    it does the setfocus, docmd acCmdPaste and then correctly processes the data previously
    pasted there. Hmmmm. It's like the acCmdPaste does nothing at all with no error indication.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Right click copy or ctrl+c should fill the clipboard equally well.

    I used the Click event of textbox.
    Last edited by June7; 07-16-2013 at 02:50 PM.
    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.

  6. #6
    dickn is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Victoria BC, Canada
    Posts
    15
    Well I solved the problem.

    I made a dummy form with just a button and an unbound text field.
    I copied data to the clipboard and then clicked the button on the form.
    The text box filled up with the data but when I tried to use MsgBox to display
    the data there was none!!! Hmmm.

    So I inserted a Me.Refresh after the DoCmd.RunCommand acCmdPaste and then
    the MsgBox displayed the data!!

    So what's going on here? Is this normal or due to using an unbound field?
    I'll go back to my other system (with the problem) and see if the Refresh does the trick.
    I'll post a reply if that solves the problem.

  7. #7
    dickn is offline Novice
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Victoria BC, Canada
    Posts
    15
    That was it!!

    Works as advertised so long as I have it his way:

    Me.Text.Setfocus
    DoCmd.RunCommand acCmdPaste
    Me.Refresh ' <<<<< Must do this
    MsgBox ("Data read is: " & Me.Text)

    I'd still like to know if this is a bug or a feature or how it's meant to be.
    For now, problem solved.

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I think the reason is that must exit the textbox so its Value property is set or run code to refresh form and hence set Value property.

    Alternative to Refresh is use two events:

    Private Sub Text83_Click()
    DoCmd.RunCommand acCmdPaste
    'either set focus to another control so the AfterUpdate will run or press Enter key
    End Sub

    Private Sub Text83_AfterUpdate()
    MsgBox ("Data read is: " & Me.Text83)
    End Sub
    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.

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

Similar Threads

  1. Replies: 10
    Last Post: 03-12-2013, 01:41 PM
  2. How to undo acCmdPaste ???
    By focosi in forum Programming
    Replies: 12
    Last Post: 09-25-2011, 01:48 PM
  3. Replies: 0
    Last Post: 06-17-2010, 04:51 AM
  4. DoCmd.RunCommand acCmdSaveRecord
    By Rick West in forum Programming
    Replies: 3
    Last Post: 04-22-2010, 02:52 PM
  5. Replies: 5
    Last Post: 03-30-2010, 12:53 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