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?
"DoCmd.GoToRecord , , acLast" HELP
Collapse
X
-
Tags: None
-
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.SubFormContr ol.SetFocus
' Now set focus to a control on the SubForm
Me.SubFormContr ol.FORM.Control Name.SetFocus
' Now move to the last record of the SubForm
DoCmd.RunComman d acCmdRecordsGoT oLast -
-
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.SubFormContr ol.SetFocus
' Now set focus to a control on the SubForm
Me.SubFormContr ol.FORM.Control Name.SetFocus
' Now move to the last record of the SubForm
DoCmd.RunComman d acCmdRecordsGoT oLast "" I received an error that said there was no "SubFormControl ". So i'm back to square one. Anyone??Comment
-
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.Comment
-
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)Comment
-
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.Comment
-
That worked marvelously, thank you.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.Comment
-
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>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.
Success with your application, I'm sure it will be a good one as you're thinking things through thoroughly !
Nic;o)Comment
Comment