DAO and key number.

User avatar
sal21
PlatinumLounger
Posts: 4364
Joined: 26 Apr 2010, 17:36

DAO and key number.

Post by sal21 »

this is an old project...

In a table1 have a key autonumber named ID.

now i add new set of fields with:

rs.addnew
...
rs.update

but after update, and without a query, is possible to know the number of new ID key number and add the value in MYVar?

User avatar
HansV
Administrator
Posts: 78573
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DAO and key number.

Post by HansV »

The new AutoNumber value is available when you execute AddNew:

Code: Select all

    rs.AddNew
    MyVar = rs.ID
    ...
    rs.Update
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4364
Joined: 26 Apr 2010, 17:36

Re: DAO and key number.

Post by sal21 »

HansV wrote:The new AutoNumber value is available when you execute AddNew:

Code: Select all

    rs.AddNew
    MyVar = rs.ID
    ...
    rs.Update
work! buit i have changed rs.ID in rs!ID.

with rs.ID, i have error

User avatar
HansV
Administrator
Posts: 78573
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: DAO and key number.

Post by HansV »

Yes, that's better. :thumbup:
Best wishes,
Hans