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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form and subform question 1

Status
Not open for further replies.

MrMajik

IS-IT--Management
Apr 2, 2002
267
I have a form that contains a subform. I also created the navigation buttons using these commands:

DoCmd.GoToRecord , ,acFirst
DoCmd.GoToRecord , ,acPrevious
DoCmd.GoToRecord , ,acNext
DoCmd.GoToRecord , ,acLast

Both the form and subform have these buttons. Here is the situation:

When the form opens I can get the form and subform to display the contents of the last record. However, when I click a navigation button on the form the data displayed in the subform always reverts back to the first record. I have to click the DoCmd.GoToRecord , ,acLast button in the subform to get the data to move to the last record.

Do you know what code will move the data in the subform to the last record when one of my navigation buttons in the form is clicked?

Thank you.
 
This button on the form refers to the recordset on the form so if you want button on your form to move the recordset in your subform use the following on the on click event of your navigation button : YourSubform.form.recordset.moveLast (or move next, previous or first).
 
EvilCabal;

When I tried your suggestion I got an error. Here is how I set up the command:

Form is called Members
Subform is called Accounts Subform
Table I want to move to the last record is Accounts

I thought this would work but generated an error:
[Accounts Subform].Members.Accounts.MoveLast

Can you tell me what is wrong?

Thank you.
 
If I get you right your subform is bound to the Accounts table. If it's so, this should work :

[Accounts Subform].Form.Recordset.MoveLast

Try avoiding spaces in control names as it tends to cause confusion and errors.
 
EvilCabal;

That did it!

Thank you :)

MrMajik
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top