How can I put the 'cursor' on the newly created record, after requery?

mardi 14 avril 2015

Hi, I'm new here but have benefited greatly from this forum already. I'm in the superuser category rather than a fully fledged programmer.



Please could someone help me on this. I've searched extensively but can't find a way around what must be a straightfowrd issue.



I launch a 'CreateNewRecords' form from a 'MainForm' form. When the 'CreateNewRecords' form closes, the new record is visible on 'Main Form'.



The underlying query is unsorted, so this code in the AfterUpdate event of 'CreateNewRecords' puts the cursor on the last record displayed on 'MainForm', which is the newly created record:

Forms!frmMainForm.Requery

With Forms!frmMainForm.RecordsetClone

.MoveLast

Forms!frmMainForm.Bookmark = .Bookmark

End With



However, I intend to sort the underlying query, which means that a newly created record may appear in the middle of the records displayed on 'MainForm'.



What I want to have happen is that after a new record is created by 'CreateNewRecords', the underlying query is requeried so that all current records are displayed on 'MainForm' but also that the cursor rests on the newly created record (rather than default to the first record).



Please help me with a code snippet that will achieve this.



many thanks

How can I put the 'cursor' on the newly created record, after requery?

0 commentaires:

Enregistrer un commentaire

Labels