By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,045 Members | 1,760 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,045 IT Pros & Developers. It's quick & easy.

Capture AutoNumber ID with AddNew method

P: n/a
I'm creating a new row in a table with via the AddNew method, where the
table ID is an Autonumber field. I want to capture the value of the ID
after I create the row. There are no other unique indices in the
table. Can I do this?

Thanks in advance.

Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
William Ortenberg <bi*****@pacbell.net> wrote in
news:Hd******************@newssvr27.news.prodigy.c om:
I'm creating a new row in a table with via the AddNew method,
where the table ID is an Autonumber field. I want to capture
the value of the ID after I create the row. There are no
other unique indices in the table. Can I do this?

Thanks in advance.
Sure, after you issue the .addnew but before the .update to store
your record, you can set the ID to a memvar

..addnew
memvar = !ID
..update

Bob


Nov 12 '05 #2

P: n/a
"William Ortenberg" <bi*****@pacbell.net> wrote in message
news:Hd******************@newssvr27.news.prodigy.c om...
I'm creating a new row in a table with via the AddNew method, where the
table ID is an Autonumber field. I want to capture the value of the ID
after I create the row. There are no other unique indices in the
table. Can I do this?

Thanks in advance.


I think this is what you mean.

With MyRecordset
.AddNew
![Field1] = Value1
![Field2] = Value2
MyID = ![AutonumberField] 'Autonumber value created when we
started adding the record
.Update
End With

ie. Get the value of your Autonumber field before your use the Update
method.
--
Bradley
Software Developer www.hrsystems.com.au
A Christian Response www.pastornet.net.au/response
Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.