Share via

Detecting using "CTRL V" to insert a record

Anonymous
2017-04-28T11:59:37+00:00

I want to let the users create records in a table by copy/paste.

They can copy the whole record by "CTRL C" eventhough one of the fields is LOCKED - Ive tested by inserting into Word.

When they will insert the record by "CTRL V" the locked field if NOT filled with data of cause.

Can I in some way detect when "CTRL V" is used and for a moment UN-lock the field while inserting and then LOCK it again ?

If so how ?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2017-04-30T20:42:18+00:00

In a table datasheet, I don't think there's any way you can do this.  Are you really letting your users enter data directly in table datasheets?  I'm guessing, since you say one of the fields is locked, that this is actually happening on a form, not on a table datasheet.

If your users are actually doing this on a form, even in datasheet view, then I can imagine a way that *might* work -- I haven't tested it.  You could set the form's KeyPreview property to True, and use the KeyDown event to test whether the key combination that was pressed is Ctrl+V or Shift+Insert.  If so, then you could unlock the field in question.  Then in the form's Current event you could lock the field again. 

Maybe that would work, though only on a form, not on a table datasheet.  However, it would not capture other methods whereby the user could insert a record from the clipboard; not even their use of Copy, Paste Append from the ribbon.  On a form, it would be better to have a command button to clone the current record.  Then the code behind that button would take care of it all:

    RunCommand acCmdSelectRecord

    RunCommand acCmdCopy

    Me.MyLockedField.Locked = False

    Runcommand acCmdPasteAppend

    Me.MyLockedField.Locked = True

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-04-30T21:15:11+00:00

    Yeah, you're right - it's in a form of cause !

    I think that "clone-button" is the way to go !

    Thx for your answer !

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-04-30T05:44:59+00:00

    Really ... no one have some ideas here ?

    Was this answer helpful?

    0 comments No comments