@@IDENTITY Works fine in access2000+
Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "/Allt I Allo.mdb;User ID=Admin;Mode=Share Deny None")
myConnection.Open()
Dim MyCommand As New OleDbCommand("INSERT INTO test (hej1, hej2) VALUES ('hej3', 'hej4')", MyConnection)
' This is your missing command your need to run the INSERT Query before getting your ID
MyCommand.ExecuteNonQuery()
' Get the Last INSERT ID
MyCommand.CommandText = "SELECT @@IDENTITY"
MsgBox("Last ID was : " & MyCommand.ExecuteScalar())
MyConnection.Close()
MyCommand.Dispose()
Andy