Copy/Paste Record Problem

  • Thread starter Thread starter Rob Parker
  • Start date Start date
R

Rob Parker

Yesterday, I had a user report a problem to me, related to copying and
pasting an existing record into a new record. I've spent much of today
trying to figure out exactly what happens, and how to prevent this in
future - with little success - and looking for incorrect records in the
existing data (fortunately only a couple of records).

Details: Using Access 2000, SP-3. Continuous form, with record selectors
visible, and additions allowed (both these settings are required by users).
The form is bound to a table, and about half of the fields in the table are
visible in bound controls in the form; the others are set by either a
default value in the table (entry date), or via code in the form's OnInsert
event which uses values from some combo-boxes or hidden text-boxes in the
form's header (the code also does some validation).

Select an existing record by clicking on its record selector, then Copy
(either from Edit menu, or via keyboard shortcut key); set the appropriate
entries in the combo-boxes in the header; click on the record selector for a
new record at the bottom of the form, and Paste (again, either from Edit
menu or shortcut key).

Result: a new record is created, with entries in those fields which have
default values, but with none of the data from the copied record. And the
KILLER: the data from the visible fields in the copied records overwrites
the data for another (random) existing record; the other data (from the
combo-box values/hidden textboxes) is not overwritten.

I've searched the newsgroups with no success. I've also browsed the Access
Web site, and thought that perhaps the items regarding bookmark bugs might
help (even though the code does not use bookmarks - perhaps used internally
by the Jet engine in this case (I thought, clutching at straws)); sadly, no
joy there.

I'm at a loss as to how to detect that the user is doing this copy/paste
operation, and trap/prevent it. Any suggestions on that would be gratefully
received. Also an explanation of why this is occurring would be
appreciated. I could remove the standard menus and replace them with custom
ones, without the copy/paste options; but since this can also be done via
keyboard shortcuts (and is another carved-in-stone user requirement, to
allow copying between fields in different records on occasion) it wouldn't
prevent the problem. Similarly, hiding the record selectors or dis-allowing
additions in the continuous form (there is also a "details" form, which
exposes all fields to the user) would prevent this, but I can't do that
either.

TIA,

Rob
 
Haven't tried that, and can't until I'm back at work tomorrow. But I'll try
then, and post result tomorrow evening (my time - GMT-10); sadly I can't
access newsgroups from workplace.

Rob
 
This will prove the record can be copied and the table can accept the same
data a second time. If this fails doing it through the UI, hopefully you'll
get a more meaningfull message (like PK violations). Of course if it works,
you could automate using sendkeys!!
 
John, sorry I didn't see your last post last night. Could have told you
straight away that it wouldn't be a PK violation - the PK is an autonumber
field.

I've tried your suggestion, and get exactly the same result as I described
previously. No error message of any sort, just a new record with default
data, AND a corrupted record elsewhere in the table.

Open to further suggestions from you, or anyone else following this thread.
In particular, how can I trap this action by the user (and cancel it, and
tell them they can't do it that way!)?

Rob
 
Back
Top