Duplicating a record, how do I get the new Autonumber?

S

Santiago Gomez

I am duplicating a record. I want to get at the AutoNumber ID for the new
record. How can I do it?

Set rs = Me.RecordsetClone()

rs.AddNew
rs!PrimaryBusID = PrimaryBusID
rs!FeederID = FeederID
rs!SecondaryBusID = SecondaryBusID
rs!SubBus1ID = SubBus1ID
rs!SubBus2ID = SubBus2ID
rs!SubBus3ID = SubBus3ID
rs!SubBus4ID = SubBus4ID
rs!Load = Load
rs![Notes #2] = [Notes #2]
rs![Notes #1] = [Notes #1]
rs![Connected HP] = [Connected HP]
rs![Efficiency] = [Efficiency]
rs![PF] = [PF]
rs![Load Factor] = [Load Factor]
rs![Percent Runtime] = [Percent Runtime]
rs![On/Off] = [On/Off]
rs.Update

Debug.Print rs!FeederloadID

the last line print the id of the original record, not the new autonumber.

thanks
 
T

TC

From memory, the Update method repositions the recordset; so you are >not<
positioned on the just-added record. You can reposition to it like this:

rs.bookmark = rs.lastupdated ' rs.lastmodified?

I never remember which of those two props it is. Online help will readily
tell you.

HTH,
TC
 

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