DoCmd.GoToRecord , , acLast

P

Pedro

Hello everyone
I have this procedure and suddnely it's not working.
I'm not an expert but it was ok.
It's like this :

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acLast
End Sub

And when i open this form, it goes to another record when it's suppose to go
to the last one.
Any ideas? Please help me.
Tks in advance
Pedro
 
D

Douglas J. Steele

Try putting that code into the Load event, rather than the Open event.

The Open event fires before all of the data has been retrieved.
 
A

Allen Browne

You might get a better result by using the form's Load event:

Private Sub Form_Load()
If Not Me.NewRecord Then
RunCommand acCmdRecordsGotoLast
End If
End Sub
 
P

Pedro

Ok. It's working. Last one :
Now if i would like to go to the highest value of a field and show me all
the record?
It's a numeric one.
ty in advance
Pedro
 
A

Allen Browne

How about sorting the form so the highest value loads first:

Private Sub Form_Load()
Me.OrderBy = "[YourNumericFieldNameHere] DESC"
Me.OrderByOn = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top