By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,136 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,136 IT Pros & Developers. It's quick & easy.

"DoCmd.GoToRecord , , acLast" HELP

100+
P: 135
My database has a form used to view maintenance for selected equipment. I select the equipment item from a combo box; the subform is then updated with all the relevant maintenance for that equipment item (master/child field linked on equipmentID). The maintenance subform is in datasheet view. Here is the problem: I can't figure out how to have the maintenance subform goto the last record after the equipment item is selected in the combo box on the main form. I thought to use the afterupdate event of the combo box on the main form. I just can't figure out how to tell the subform to goto or setfocus on the last record of the subform. ???????? Advice?
Dec 27 '08 #1
Share this Question
Share on Google+
10 Replies


RuralGuy
Expert 100+
P: 375
Here's how I would do it. In the AfterUpdate event of the ComboBox on the MainForm I would put:
' First set focus to SubFormControl
Me.SubFormControl.SetFocus
' Now set focus to a control on the SubForm
Me.SubFormControl.FORM.ControlName.SetFocus
' Now move to the last record of the SubForm
DoCmd.RunCommand acCmdRecordsGoToLast
Dec 27 '08 #2

100+
P: 135
Thank you, I'll a try give it. What do you mean by a "control"? on the subform?
Dec 27 '08 #3

nico5038
Expert 2.5K+
P: 3,072
Why not sort the subform descending ?
Thus the most recent is always on top.

Nic;o)
Dec 27 '08 #4

100+
P: 135
@nico5038
Yes, I could do that... but I want the most recent to be at the bottom and then scroll back through to view older entries. The datasheet shows ten entries before having to scroll. I dunno, it just seems more logical to scroll back through the older records. Also, in descending i would still have to scroll to the bottom of the datasheet to make a new entry. Would like to be able to see the most recent entries and also be able to make a new entry. Anyway, I tried ""' First set focus to SubFormControl
Me.SubFormControl.SetFocus
' Now set focus to a control on the SubForm
Me.SubFormControl.FORM.ControlName.SetFocus
' Now move to the last record of the SubForm
DoCmd.RunCommand acCmdRecordsGoToLast "" I received an error that said there was no "SubFormControl". So i'm back to square one. Anyone??
Dec 27 '08 #5

RuralGuy
Expert 100+
P: 375
You have to use the name of your SubFormControl. Forms are displayed on other forms by means of a SubFormControl and it is the name of this control that is required first. Often it is named the same as the Form it is displaying. Fields are displayed on forms by means of controls. Often this is a TextBox control. Again, you *must* use your names for these elements and not my generic discription names.
Dec 27 '08 #6

nico5038
Expert 2.5K+
P: 3,072
For most users scrolling down for older entries is rather "natural".

Personally I would add another (With property "Dataentry" set to "Yes") subform to let the user add a new row. Thus (s)he never has to reposition in the datasheet subform.

Nic;o)
Dec 27 '08 #7

100+
P: 135
@nico5038
I disagree. =) When I write on a notepad I generally write from top to bottom. ; )
Same as in a Word or other type of document. Top to bottom. The most recent line being above the line being written. So it seems most natural to scroll back up to view what has already been read/written. I will, however, ponder the idea of a second subform for adding a new row.
Thanks for the help.
Dec 28 '08 #8

100+
P: 135
@RuralGuy
That worked marvelously, thank you.
Dec 28 '08 #9

nico5038
Expert 2.5K+
P: 3,072
@MyWaterloo
You're correct within the scope of the layout of a document, but by stacking documents on a pile the most recent will be on top and you'll need to dig "down" for the older ones <LOL>

Success with your application, I'm sure it will be a good one as you're thinking things through thoroughly !

Nic;o)
Dec 28 '08 #10

RuralGuy
Expert 100+
P: 375
@MyWaterloo
You're very welcome. Glad I could help.
Dec 28 '08 #11

Post your reply

Sign in to post your reply or Sign up for a free account.