SCOPE_IDENTITY in MS Access ??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JAMBAI
    New Member
    • Feb 2007
    • 28

    #1

    SCOPE_IDENTITY in MS Access ??

    Does anyone know how to get the @@Identity value after the insert query and use it in VBA.

    strIns = "Insert Query"
    Docmd.RunSQL, strIns

    I am using linked DataFlex table through ODBC.

    Thanks
    Jambai
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Originally posted by JAMBAI
    Does anyone know how to get the @@Identity value after the insert query and use it in VBA.

    strIns = "Insert Query"
    Docmd.RunSQL, strIns

    I am using linked DataFlex table through ODBC.

    Thanks
    Jambai
    In SQL Server SELECT @@identity will retrieve the value of @@identity after an Insert Operation as in:

    [CODE=sql]CREATE Table YourTable (col1 int not null IDENTITY (1, 100), col2 char(5) not null)
    Go
    INSERT YourTable (col2) VALUES ('some 5 character value')
    SELECT @@identity ==> returns 1[/CODE]
    In my mind, the only conceivable way to reference the value returned from SELECT @@identity, and use it in VBA, is through some kind of Variable assignment. I don't even know if that is possible and I'm not at all familiar with DataFlex. Sorry I could not help you more.

    Comment

    Working...