Gotolast record (or not)

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

Guest

I've got a macro that opens a form and goes to the last record in this form
(Gotorecord). Only when the forms opens, it goes to the first record.
Probably something in the properties of the form that causes this. Anyone got
a clue?

Thanx

Paul
 
When posting a question about code that does not behave as expected it
always helps to post the code. A few questions: Is it really a macro, or
is it a VBA procedure? How did you create the code? From where do you run
the code (command button on a form, or what exactly)?
 
It's really a macro with two commandlines:

Openform (name form)
Gotorecord (last)

The macro is executed when the form is opened
 
You say the macro is executed when the form is opened, but the command to
open the form will occur when the form is closed. If the form is open it
doesn't need to be opened again. The macro to go to the last record could
occur in the form's Open event. Your reply leaves my second two questions
unanswered, so I can only guess that you are opening the form using a
command button on another form. That is where you will have the code for
opening the form. The form you open is where you place the code to direct
it to the last record.

If you are using Access 2000 or later you would do well to use VBA. In the
form's Open event add the following:

DoCmd.GoToRecord, , acLast

The command button wizard will help you create a button to open the form.
If you create the command button's Click event yourself it will be something
like:

DoCmd.OpenForm "FormName"

Substitute the actual form name within the quotes. I would be glad to offer
assistance with either of these procedures, but I will await your response,
as you may already be familiar with adding the code.
 
Thanx Bruce, I've tried it and it works. Still wondering why the form didn't
go to the last record when executing the macro (that started from a command
butto, yes :))

Thank you!
 

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

Back
Top