Opening form on last record

MikeAngelastro

Registered User.
Local time
Today, 04:53
Joined
Mar 3, 2000
Messages
254
Hi,

How do I open a form using code so that it comes up on the last record of its record source?

Thanks,

Mike
 
Put this in the forms OnOpen event...

DoCmd.RunCommand acCmdRecordsGoToLast

HTH
 
Hi,

Thanks for the suggestions. I looked into directormac's suggestion and used the following code, which worked:

DoCmd.GoToRecord , , acLast

I have to say that this is not very intuitive. It's the same kind of situation when you want to close a form. These should be methods of the form. For instance, if you want to close the form, Me.Close should do it instead of DoCmd.Close. If you want to move to the last record, Me.MoveLast should do it. Etc.

I suppose I could create subs(methods) in the form's module called "Close" or "MoveLast" that use the DoCmd object, but that is extra work that really should not be necessary.

The suggestion by ghudson I'm sure works though I haven't tried it, but I find it even less intuitive than the DoCmd approach. MS sometimes gives gives us ten ways of doing something except the most logical way.

Thanks again,

Mike
 

Users who are viewing this thread

Back
Top Bottom