AddNew and Update ADO methods 
Author Message
 AddNew and Update ADO methods

In my application, I've avoiding the use of the ADODC for various
reasons so I'm reproducing much of the funcionality myself.

I've got a question about .AddNew and .Update methods, particularly wrt
Access databases.

If I add a new record to a recordset without passing any parameters (its
empty so far) what is contained in the record? The problem is that I've
got an autonumber field for my primary key. Can I count on having my new
ID number?

My current fix is to do the following:

Dim RS as Recordset
Dim tmpBookMark As Variant

RS.addnew
RS.Update
tmpBookMark = empRS.Bookmark
RS.Requery
RS.Bookmark = tmpBookMark

Now I don't know if that'll work. Please help.



Sun, 06 May 2001 03:00:00 GMT  
 AddNew and Update ADO methods
With an autonumber, anytime you addnew, you increment the number, so yes you
will have a record, that will have your autonumber field, and nothing else
by doing that.  One caution though, is to make sure your tables allow for
blank fields, by setting the proper field properties in the design view of
the table itself.

HTH
Wendy

Quote:
>In my application, I've avoiding the use of the ADODC for various
>reasons so I'm reproducing much of the funcionality myself.

>I've got a question about .AddNew and .Update methods, particularly wrt
>Access databases.

>If I add a new record to a recordset without passing any parameters (its
>empty so far) what is contained in the record? The problem is that I've
>got an autonumber field for my primary key. Can I count on having my new
>ID number?

>My current fix is to do the following:

>Dim RS as Recordset
>Dim tmpBookMark As Variant

>RS.addnew
>RS.Update
>tmpBookMark = empRS.Bookmark
>RS.Requery
>RS.Bookmark = tmpBookMark

>Now I don't know if that'll work. Please help.



Sun, 06 May 2001 03:00:00 GMT  
 AddNew and Update ADO methods
I believe you will get a new record with NULLs and default fields. You can
use String for your bookmarks. The LastModified property will give you the
location of the new record after the Update.
I don't think you have to do the Requery either.
HTH
--
Gary (MCT, MCPS, MCSD)
http://www.enter.net/~garyl/  for references to good books

ICQ 6375624

Quote:
>In my application, I've avoiding the use of the ADODC for various
>reasons so I'm reproducing much of the funcionality myself.

>I've got a question about .AddNew and .Update methods, particularly wrt
>Access databases.

>If I add a new record to a recordset without passing any parameters (its
>empty so far) what is contained in the record? The problem is that I've
>got an autonumber field for my primary key. Can I count on having my new
>ID number?

>My current fix is to do the following:

>Dim RS as Recordset
>Dim tmpBookMark As Variant

>RS.addnew
>RS.Update
>tmpBookMark = empRS.Bookmark
>RS.Requery
>RS.Bookmark = tmpBookMark

>Now I don't know if that'll work. Please help.



Sun, 06 May 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. addnew and update methods ?

2. AddNew and Update Methods for Dynaset multiple tables

3. Update: Problems using AddNew method of Recordset

4. Addnew and update method in ADOCE not working ?

5. .addnew method ADO does not work pls help

6. Problem with ADO Recordset AddNew method

7. ADO AddNew method

8. Oracle, ADO question (addnew method from VB)

9. using ado addnew method w/ asp

10. error msg 3251 on AddNew method for ADO/Brand New Jet database

11. ADO + Access97: please help with AddNew-Method

12. ADDNEW-Method on ADO with SQL-Server [Newbie]

 

 
Powered by phpBB® Forum Software