Set Focus To Last Record Entered

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Could someone help me with this embarassingly simple code. After adding a new record to a subform, I have the afterupdate event set to requery so that the records, including the new one, are all in order. Question is, is there any way to set the focus on the last record that was entered. e.g. still show the records in order but have the focus jump down the list to the last record entered.
 
Could someone help me with this embarassingly simple code. After adding a new record to a subform, I have the afterupdate event set to requery so that the records, including the new one, are all in order. Question is, is there any way to set the focus on the last record that was entered. e.g. still show the records in order but have the focus jump down the list to the last record entered.

After the Requery put:

DoCmd.GoToRecord acLastRecord
 
Thanks John but that doesn't do it. What it does do, is take me to the Last record in the dataset, not the last record that I entered. For example, if my last entry was the word "science", after requerying the form, the record "science" would now be in alphabetical order inbetween the records "photography" and "xray". With the gotorecord aclast code, this puts the cursor (focus) on xray, when I would like it to be on science. If this can't be done, its not situation critical as I kind of thought it would just be cool for the user to see that their new record was entered, and is now in alphabetical order.

----- John Vinson wrote: ----

On Fri, 9 Apr 2004 17:56:05 -0700, "MBoozer
Could someone help me with this embarassingly simple code. After adding a new record to a subform, I have the afterupdate event set to requery so that the records, including the new one, are all in order. Question is, is there any way to set the focus on the last record that was entered. e.g. still show the records in order but have the focus jump down the list to the last record entered.


After the Requery put

DoCmd.GoToRecord acLastRecor

John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=publi
 
Thanks John but that doesn't do it. What it does do, is take me to the Last record in the dataset, not the last record that I entered. For example, if my last entry was the word "science", after requerying the form, the record "science" would now be in alphabetical order inbetween the records "photography" and "xray". With the gotorecord aclast code, this puts the cursor (focus) on xray, when I would like it to be on science. If this can't be done, its not situation critical as I kind of thought it would just be cool for the user to see that their new record was entered, and is now in alphabetical order.

It's a bit more of a chore but it can be done. You'ld need to:

1. Record the Primary Key of the record in the form's BeforeUpdate
event (or AfterUpdate, it's still there) in a variable
2. Requery the form
3. Open its RecordsetClone as a recordset
4. Use FindFirst to locate the record with the stored ID
5. Set the Form's Bookmark property to the Bookmark of the recordset
 
Thanks a million John. Works great. I sure appreciate the newsgroup community and the excellent advice and coding provided by people like yourself who take the time to help each other out. I, and I am sure all others, greatly appreciate it. Thanks again

Mik


----- John Vinson wrote: ----

On Sat, 10 Apr 2004 06:56:02 -0700, "MBoozer
Thanks John but that doesn't do it. What it does do, is take me to the Last record in the dataset, not the last record that I entered. For example, if my last entry was the word "science", after requerying the form, the record "science" would now be in alphabetical order inbetween the records "photography" and "xray". With the gotorecord aclast code, this puts the cursor (focus) on xray, when I would like it to be on science. If this can't be done, its not situation critical as I kind of thought it would just be cool for the user to see that their new record was entered, and is now in alphabetical order.

It's a bit more of a chore but it can be done. You'ld need to

1. Record the Primary Key of the record in the form's BeforeUpdat
event (or AfterUpdate, it's still there) in a variabl
2. Requery the for
3. Open its RecordsetClone as a recordse
4. Use FindFirst to locate the record with the stored I
5. Set the Form's Bookmark property to the Bookmark of the recordse


John W. Vinson[MVP]
Come for live chats every Tuesday and Thursday
http://go.compuserve.com/msdevapps?loc=us&access=publi
 
Back
Top