help with incrementing

G

Guest

I am using the following code to increment the ID field by one:
Dim v_Max As String
v_Max = Format(DMax("ID", "tblkpGendertst") + 1, "000")
Me.ID = v_Max
the code is in the ID after update event. The code works if the user is
entering the data manually one at the time. However, when the user pastes
multiple records on the form, which is a datasheet view, the code assigns the
same ID without incrementing. I need help! how can I have the code increment
in the scenario of copy and paste. It is important to give the user the
capability to copy and paste. please help.
thanks
Al
 
G

Graham Mandeno

Hi Al

Is it practical for you to change your ID field to an autonumber? This will
solve the paste problen, bit give you less problem over the values in the
field.

If that's a no-go, then I'm afraid you will just have to add the records one
at a time.
 
N

Nikos Yannacopoulos

Al,

If Autonumber won't work for you, then you can use an intermediate table for
the users to paste into (not including the ID field), and use some code (a
recordset operation) to append the records from there to the destination
table while calculating the ID field.

HTH,
Nikos
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top