Position on inserted record 
Author Message
 Position on inserted record

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.

Any ideas would be greatly appreciated.  

Thanks in anticipation

Andy Gurd

March Systems Ltd




Tue, 27 Oct 1998 03:00:00 GMT  
 Position on inserted record

Quote:
> After performing the UpdateRecord I would like the current (displayed)
> record to be that just inserted.

Perhaps the LASTMODIFIED property would give you this.
It retains the bookmark of the last updated or added
record...remember it contains a bookmark string
so RS.BOOKMARK = RS.LASTMODIFIED

BazInOz



Mon, 02 Nov 1998 03:00:00 GMT  
 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.

You could explicitly move the record pointer to the record that you have just
inserted.
Ex : dim ds as dynaset
 ds.findfirst criterea
 i.e ds.findfirst "Empno = " & txtEmpNo.text
I presume this works

Regards,
Srini.



Tue, 03 Nov 1998 03:00:00 GMT  
 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. :-)




Wed, 04 Nov 1998 03:00:00 GMT  
 Position on inserted record


Quote:
Gurd) writes:
>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.

Hi Andy,

as far as I know will new records be added to the _END_ of the dynaset,
they won't be sorted until you recreate the dynaset with the
Refresh-Method.
At least this is true for VB3.0 pro/Jet 2.0.
When the new record is written to the database with the
Update[Record]-Method, the pointer will return to the one which was
current before AddNew.
Performing a MoveLast will return you to the last added record. So if you
leave out the Refresh, it should work.

Hope it helps

Thomas

*****
If you are well, don't worry ... it will pass over.
*****



Sat, 07 Nov 1998 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Inserting records at specific position!

2. Inserting records at specific position!

3. ADO, Record Set Positioning - SQL - Browse Records

4. need ID from newly inserted record (altered by insert trigger on SQL server)

5. Inserting a new record between existing records?

6. Inserting a new record between existing records?

7. going to next record after inserting a new record

8. record locking while insert new record??

9. Inserting shape on fixed position on different pages

10. insert text at cursor position

11. insert at cursor position

12. Inserting a range at the cursor position

 

 
Powered by phpBB® Forum Software