I have a subform in datasheet view that I need to copy and paste multiple records into from an excel spreadsheet. The pasted data goes to a table that has an autonumber field as the primary key. I want to change the autonumber field to one that enters values incrementally based on VBA code to maintain incrementation when records are deleted (the autonumber field creates a gap in the incrementation when records are deleted).
The problem is this - If I simply enter records one at a time, the code that I am using for creating incremental values works just fine. If I try to copy/paste multiple records from excel the data pastes just fine but no incremental values are entered into the table. In contrast, if I use autonumber the values are entered as I want when I copy/paste multiple records.
How can I get my new "incrementation" code to enter values into the pasted records the way autonumbering does? I have tried running the code "after update", "on change" and "on enter" and none of these worked.
Thanks!
Todd
The problem is this - If I simply enter records one at a time, the code that I am using for creating incremental values works just fine. If I try to copy/paste multiple records from excel the data pastes just fine but no incremental values are entered into the table. In contrast, if I use autonumber the values are entered as I want when I copy/paste multiple records.
How can I get my new "incrementation" code to enter values into the pasted records the way autonumbering does? I have tried running the code "after update", "on change" and "on enter" and none of these worked.
Thanks!
Todd