"DoCmd.GoToRecord , , acLast" HELP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • MyWaterloo
    New Member
    • Dec 2007
    • 135

    "DoCmd.GoToRecord , , acLast" HELP

    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?
  • RuralGuy
    Recognized Expert Contributor
    • Oct 2006
    • 375

    #2
    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

    Comment

    • MyWaterloo
      New Member
      • Dec 2007
      • 135

      #3
      Thank you, I'll a try give it. What do you mean by a "control"? on the subform?

      Comment

      • nico5038
        Recognized Expert Specialist
        • Nov 2006
        • 3080

        #4
        Why not sort the subform descending ?
        Thus the most recent is always on top.

        Nic;o)

        Comment

        • MyWaterloo
          New Member
          • Dec 2007
          • 135

          #5
          Originally posted by nico5038
          Why not sort the subform descending ?
          Thus the most recent is always on top.

          Nic;o)
          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

          • RuralGuy
            Recognized Expert Contributor
            • Oct 2006
            • 375

            #6
            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

            • nico5038
              Recognized Expert Specialist
              • Nov 2006
              • 3080

              #7
              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

              • MyWaterloo
                New Member
                • Dec 2007
                • 135

                #8
                Originally posted by nico5038
                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)
                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

                • MyWaterloo
                  New Member
                  • Dec 2007
                  • 135

                  #9
                  Originally posted by RuralGuy
                  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.
                  That worked marvelously, thank you.

                  Comment

                  • nico5038
                    Recognized Expert Specialist
                    • Nov 2006
                    • 3080

                    #10
                    Originally posted by MyWaterloo
                    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.
                    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)

                    Comment

                    • RuralGuy
                      Recognized Expert Contributor
                      • Oct 2006
                      • 375

                      #11
                      Originally posted by MyWaterloo
                      That worked marvelously, thank you.
                      You're very welcome. Glad I could help.

                      Comment

                      Working...