• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1885
  • Last Modified:

SELECT IDENT_CURRENT command for access

Is there an identical comman in Access as SELECT IDENT_CURRENT that I can use?  I am trying to execute the following script:
'Get current primary key
sGetID = "SELECT IDENT_CURRENT(Table)"
rs.Open sGetID, conn, 1, 2
session("sGetID") = rs(0)
rs.Close

'End get Primary key

The error is as follows:

Microsoft JET Database Engine error '80040e14'

Undefined function 'IDENT_CURRENT' in expression.
0
Insomniac_PhD
Asked:
Insomniac_PhD
  • 5
  • 2
1 Solution
 
fritz_the_blankCommented:
There isn't. Are you trying to capture the new record Id from an autoincrement field when you add a new record in Access?

FtB
0
 
Insomniac_PhDAuthor Commented:
Yup.
0
 
fritz_the_blankCommented:
Here is how I do it:

strSQL = "SELECT * FROM tblYourTable WHERE 0=1"
objRS.Open strSQL,objConnection,3,3
objRS.AddNew()
  objRS("fldField1") = "Some value 1"
  objRS("fldField2") = "Some value 2"
objRS.Update()
intID = objRS("intID")

where objRS("intID") is your autoincrement field.


ftB
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fritz_the_blankCommented:
As far as I know, Access does not support @@Identity or any other similar function.

FtB
0
 
fritz_the_blankCommented:
It appears that someone else agrees with my approach here:

http://www.eggheadcafe.com/PrintSearchContent.asp?LINKID=117

FtB
0
 
Insomniac_PhDAuthor Commented:
ahh well. thanks anyway!
0
 
fritz_the_blankCommented:
Sorry that this wasn't what you wanted to hear,

FtB
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now