
Position on inserted record
Quote:
>>I have a VB4 form which has a data control (whose record source is a
>>recordset of type Dynaset, created by a query via ODBC to an Oracle
>database)
>>and a number of bound text boxes.
>>I have implemented an Insert button which does an AddNew and a Save
button
>>which amongst other actions does an UpdateRecord.
>>After performing the UpdateRecord I would like the current (displayed)
>>record to be that just inserted. I have tried a number of things
>>but have not got a satisfactory solution - currently I do a Refresh
>>of the data control followed by a MoveLast.
>>This is ok when the table is ordered by an auto-incrementing numeric key
but
>>otherwise does not work.
This code seams to work like you want it to:
Private Sub cmdAdd_Click()
Data1.Recordset.AddNew
End Sub
Private Sub cmdSave_Click()
Data1.UpdateRecord
Data1.Recordset.Bookmark = Data1.Recordset.LastModified
End Sub
Hope this is what you need. I'll be hounest and tell you I don't have a
clear understanding of what the Bookmark is all about, but I tested this
code with and without it and with it the inserted record remains the
current record. Without it, it did NOT remain the current record.
By the way, this code was generated by the Data Form Designer. You can
learn a lot by using that feature of VB 4.0 Prof if you have it. :-)