473,386 Members | 1,654 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Access 2002 Auto numbering key

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

Jul 6 '06 #1
1 1443
In JET 4 (Access 2000 and later), you can ask for the @@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 @@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.

<ch***************@laposte.netwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
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

Jul 6 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Steven Burn | last post by:
I'm curious, I've written a very simple PIS (personal info store) that allows one to store whatever they wish..... the problem is, when one deletes an entry, the auto-numbering isn't corrected to...
20
by: John | last post by:
Hi, I've recently upgraded from Access 97 to Access 2002 & the performance basically stinks. I have tried the following items listed below but it has only had a minor impact: 1) Upgraded Jet...
5
by: Charles McCaffery | last post by:
I have written a database with auto-numbering and now wish to remove alkl of my test data and set the auto-numbering back to one. How do I do this please? Charles McCaffery.
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: Chris | last post by:
Before I started to create table, etc to track unique form field record number assigments I thought I'd check to see if there is now a better way to do this in .NET. I have a parent form (table)...
2
by: bubblegirl | last post by:
Hi, I need help in getting this database to work well (user-friendly) by generating auto client ID. The ID is NOT the auto number that Access automatically create when there is no primary key. ...
6
by: orit | last post by:
I have a word document that contains a table. The table has 2 columns and hundreds of rows. I want to number the items in the table in the following way: In the first column, each cell will contain...
8
by: zeilak | last post by:
I am running Windows XP, Access 2002. I want to know the VB code for the following: I want to type in the ID # (it's the primary key and is auto-numbering) and then have the access form...
0
by: jimratajski | last post by:
Can anyone tell me how to automate page numbering of spawned page templates in Acrobat? I have a number of forms containing hidden page templates that I would like to be auto numbered as they are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.