Vlad Chapranov
May 26th, 1999, 08:55 AM
I need to have OrderID (Autonumber) of new record to create related record in a OrderDetail table. With DAO or Data Control it's very simple:
Data1.UpdateRecord
Data1.Recordset.Bookmark = Data1.Recordset.LastModified
Now you can reference to Data1.Recordset.Fields("OrderID") to get new OrderID.
How to perform this simple task with ADO DataControl or recordset?
To see the problem place regular DC and regular DBGrid, ADO DC and ADO Grid on the form. Connect both Data Controls to the same Table with Autonumber field and Grids to Data Controls respectively. Set AllowAddNew properties to True
and try to add new records in both grids. In regular Grid you'll see ID of new record just after you swiched to the previous record or performed
Data1.UpdateRecord
Data1.Recordset.Bookmark = Data1.Recordset.LastModified.
With ADO Grid you see "0" after you leave new record and if you come back to check the value of ID of new record, you'll find there Null.
I coudn't find anything similar to LastModified with ADO. I can only do
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.Recordset.MoveLast
Sorry for long explanation.
Any help would be appreciated.
Thank you.
Vlad
Data1.UpdateRecord
Data1.Recordset.Bookmark = Data1.Recordset.LastModified
Now you can reference to Data1.Recordset.Fields("OrderID") to get new OrderID.
How to perform this simple task with ADO DataControl or recordset?
To see the problem place regular DC and regular DBGrid, ADO DC and ADO Grid on the form. Connect both Data Controls to the same Table with Autonumber field and Grids to Data Controls respectively. Set AllowAddNew properties to True
and try to add new records in both grids. In regular Grid you'll see ID of new record just after you swiched to the previous record or performed
Data1.UpdateRecord
Data1.Recordset.Bookmark = Data1.Recordset.LastModified.
With ADO Grid you see "0" after you leave new record and if you come back to check the value of ID of new record, you'll find there Null.
I coudn't find anything similar to LastModified with ADO. I can only do
Adodc1.Recordset.Update
Adodc1.Refresh
Adodc1.Recordset.MoveLast
Sorry for long explanation.
Any help would be appreciated.
Thank you.
Vlad