Tags: access, andtherefore, auto, basic, create, database, dummy, key, microsoft, mysql, num, numbering, object, oracle, specify, sql, table

Access 2002 Auto numbering key

On Database » Microsoft Access

2,548 words with 1 Comments; publish: Wed, 02 Jan 2008 22:44:00 GMT; (25062.50, « »)

Hello,

Here is a basic question (I am an access dummy).

I create an object in a table where the key is an auto num and

therefore I do not specify the Id I my VBScript code:

qryCreation.Parameters(strParamModelName).Value= strPNDBName

qryCreation.Parameters(strParamEMI).Value= strValues(2)

qryCreation.Parameters(strParamFatherId).Value = strValues(3)

qryCreation.Parameters(strParamBlockDiagramPartId) .Value =

objDictionnaryBlockDiagramIdToName(cstBlockDiagram NamePrefix &

strValues(4))

Err.clear

On Error Resume Next

qryCreation.Execute dbFailOnError

...

How can I get the computed Id (auto num) ?

Thanks in advance

All Comments

Leave a comment...

  • 1 Comments
    • In JET 4 (Access 2000 and later), you can ask for the .ms-access.itags.org..ms-access.itags.org.IDENTITY value of

      the most recently executed action query.

      Example:

      Function ShowIdentity() As Variant

      Dim db As DAO.Database

      Dim rs As DAO.Recordset

      Set db = DBEngine(0)(0)

      db.Execute "INSERT INTO MyTable ( MyField ) SELECT 'nuffin' AS Expr1;"

      Set rs = db.OpenRecordset("SELECT .ms-access.itags.org..ms-access.itags.org.IDENTITY AS LastID;")

      ShowIdentity = rs!LastID

      rs.Close

      Set rs = Nothing

      Set db = Nothing

      End Function

      --

      Allen Browne - Microsoft MVP. Perth, Western Australia.

      Tips for Access users - http://allenbrowne.com/tips.html

      Reply to group, rather than allenbrowne at mvps dot org.

      <christophe.lemort.ms-access.itags.org.laposte.netwrote in message

      news:1152196471.702561.174620.ms-access.itags.org.75g2000cwc.googlegro ups.com...

      Quote:
      === Original Words ===

      Hello,

      >

      Here is a basic question (I am an access dummy).

      >

      I create an object in a table where the key is an auto num and

      therefore I do not specify the Id I my VBScript code:

      >

      >

      qryCreation.Parameters(strParamModelName).Value = strPNDBName

      qryCreation.Parameters(strParamEMI).Value = strValues(2)

      qryCreation.Parameters(strParamFatherId).Value = strValues(3)

      qryCreation.Parameters(strParamBlockDiagramPartId) .Value =

      objDictionnaryBlockDiagramIdToName(cstBlockDiagram NamePrefix &

      strValues(4))

      >

      Err.clear

      On Error Resume Next

      qryCreation.Execute dbFailOnError

      ...

      >

      How can I get the computed Id (auto num) ?

      >

      Thanks in advance

      #1; Wed, 02 Jan 2008 22:45:00 GMT