Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to move to last record with DoCmd.GoToRecord 1

Status
Not open for further replies.

ddiamond

Programmer
Apr 22, 2005
918
US
I have a form with a sub-form on it. The sub-form is displayed as a data-sheet grid. When the user opens the form with the sub-form, I want the sub-form to be positioned at the last record.

I tried the following in the sub-form:
Code:
Private Sub Form_Activate()
    DoCmd.GoToRecord , , acLast
End Sub
That did not appear to do anything. When I tried placing it in the form_load event, I get an error message - form not loaded.
 
place on subform "OnCurrent" event!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Well, that did move to the last record when the form opens, but it locks the user to the last record. I still want to allow the user to navigate to other records. I just want the user to start on the last record. It seems like the oncurrent event fires everytime a new record is selected on the datasheet.
 
sorry i thought you were trying to lock the user to the last record.

Do you not have the record selector buttons available? so the user can navigate around the records ?

to go to last record then simply need to click >| button.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
That is what I will do if I can't get this working. I was hoping I can automate the process.
 
I got it working with a work-around.

I created a pulic method in the subform called MoveLast:
Code:
Public Sub MoveLast()
    DoCmd.GoToRecord , , acLast
End Sub
I then called this method from the event that opens the form with the subform.
Code:
Private Sub cmdNewGLAccount_Click()
  DoCmd.OpenForm "frm_NewGLAccountNumberForm"
  Forms!frm_NewGLAccountNumberForm!frm_NewGLAccountNumberSubForm.Form.MoveLast
End Sub
 
have a star!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top