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

  • Thread starter Thread starter Santiago Gomez
  • Start date Start date
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
 
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
 
Back
Top