René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

Autoincrement (2) [DAO]

option explicit

public sub autoincrement_02()

  ' insert a biiiig autoincrement (autonumber)
  ' into the table

  dim access as Access.Application
  dim db     as Dao.Database
  dim rs     as Dao.RecordSet

  dim mdb_file_name as string 
  mdb_file_name = "c:\\temp\\dao_test.mdb"
  set access = new Access.Application

  access.OpenCurrentDatabase(mdb_file_name)
  set db = access.CurrentDb

  set rs = db.openRecordSet("some_table", dbOpentable)

  rs.addNew
  
'   rs("theAutonumberField") = ??? (Deliberatly omitted)
    rs("aDateColumn"       ) = #11/01/1517#
    rs("aCurrencyColumn"   ) = 100.01
    rs("aTextColumn"       ) = "autonumber, 2nd part"
    rs("fifthColumn"       ) = "still Chanel, no 5"

    msgBox "The autonumber field to be inserted is: " & rs!theAutonumberField

  rs.update


end sub