Results 1 to 4 of 4
  1. #1
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    316

    How to detect user pasting multiple rows into a datasheet

    I have a datasheet application that updates additional fields based on the input of one field using VBA code. Due to the design constraints, I use the following technique...



    1. After the field is updated, I do a Refresh to save the row
    2. Then I retrieve the other values I need using VBA code and save them.
    3. Finally, I read the saved row, update the additional fields, and update the row.

    This works fine as long as the operator enters the new row manually or even if he/she does a copy & paste of one row. However, if he/she copies and pastes multiple rows, then the Refresh doesn't insert the multiple rows and my step 3 above fails. Is there a way I can detect that multiple rows are being inserted so I can handle the event accordingly?

    (Please don't give me another technique to update the records, there is a reason I'm doing it this way.)

    Thanks, Eddie

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Perhaps in BeforeUpdate event set a public/global variable for the record count, check this against the record count in AfterUpdate.
    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
    EddieN1 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    May 2011
    Posts
    316
    Here's the deal. The paste part of the process works just like an operator entering the data one field at a time. Bear in mind that if a control is locked, nothing will be pasted into those controls. On the copy part the contents of only shown controls get copied. If a control isn't on the form or is hidden, its contents won't be copied.

    As far as pasting multiple rows, the update events are triggered, so you can trap before update, after update, etc. However, the data won't actually exist in the table until the operator confirms the "Okay to Paste" dialog box at the end.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Sorry, I misread your original post and on reread see my suggestion was not relevant. You can detect how many rows are selected with SelHeight property:

    intHeight = Me.SelHeight
    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: 6
    Last Post: 11-09-2011, 02:41 AM
  2. Comnbining multiple rows into one row
    By Equalizer700 in forum Queries
    Replies: 1
    Last Post: 04-19-2011, 03:51 AM
  3. Copying and pasting
    By wthoffman in forum Access
    Replies: 1
    Last Post: 04-14-2010, 04:12 AM
  4. Auto set field when pasting
    By resullivan in forum Programming
    Replies: 1
    Last Post: 01-11-2010, 01:49 PM
  5. Replies: 5
    Last Post: 12-10-2009, 10:33 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