Exit subform to main form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DAHMB
    New Member
    • Nov 2007
    • 147

    Exit subform to main form

    I have a subform named frmPackingSubEn try with one field in it called packingId. This subform is in a form called frmPacking. I would like to be able to tab out of the subform field and into the field PackingDate of the main form. Can I do this using AfterUpdate? and How?

    Thanks for any help
  • PianoMan64
    Recognized Expert Contributor
    • Jan 2008
    • 374

    #2
    Originally posted by DAHMB
    I have a subform named frmPackingSubEn try with one field in it called packingId. This subform is in a form called frmPacking. I would like to be able to tab out of the subform field and into the field PackingDate of the main form. Can I do this using AfterUpdate? and How?

    Thanks for any help
    Hey DAHMB,

    I'm sorry to say that once you're in the sub form, there isn't any access to the main form controls at all, until you simply click on a control on the main form. I'm not currently familar with any controls and or tricks that would allow you to do that.

    You may want to consider a form redesign to see if there is a way to either keep all times on the main form, or if there is a need to have a subform, then to have all the items entered on the main form before going to the sub form.

    Hope that helps,

    Joe P.

    Comment

    • ADezii
      Recognized Expert Expert
      • Apr 2006
      • 8834

      #3
      Originally posted by DAHMB
      I have a subform named frmPackingSubEn try with one field in it called packingId. This subform is in a form called frmPacking. I would like to be able to tab out of the subform field and into the field PackingDate of the main form. Can I do this using AfterUpdate? and How?

      Thanks for any help
      You can actually 'mimic' this kind of behavior. In the LostFocus() Event of the 'Last' Control in the Sub-Form in Tab Order, place the following line of code. When you press the TAB Key while you are in this Last Control in the Sub-Form, the Control will lose Focus, and subsequently place the Focus on the desired Field in the Main Form:
      Code:
      Private Sub [Last Field in Tab Order in Sub-Form]_LostFocus()
        Me.Parent![PackingDate].SetFocus
      End Sub

      Comment

      • DAHMB
        New Member
        • Nov 2007
        • 147

        #4
        Thanks thats what I needed!

        Comment

        • ADezii
          Recognized Expert Expert
          • Apr 2006
          • 8834

          #5
          Originally posted by DAHMB
          Thanks thats what I needed!
          Glad it worked out for you.

          Comment

          • pld60
            New Member
            • Aug 2009
            • 18

            #6
            Private Sub [Last Field in Tab Order in Sub-Form]_LostFocus()
            Me.Parent![PackingDate].SetFocus
            End Sub
            This works great to tab from the subform to the main form. How about going to a second subform? I can't figure out what to place in the 2nd line to give focus to a field in a subform.

            Comment

            • ADezii
              Recognized Expert Expert
              • Apr 2006
              • 8834

              #7
              Originally posted by pld60
              Private Sub [Last Field in Tab Order in Sub-Form]_LostFocus()
              Me.Parent![PackingDate].SetFocus
              End Sub
              This works great to tab from the subform to the main form. How about going to a second subform? I can't figure out what to place in the 2nd line to give focus to a field in a subform.
              The following should do the trick, assuming it's executed from within the SubForm:
              Code:
              Me.Parent![<SubForm Name>].Form![Control in SubForm Name].SetFocus

              Comment

              • pld60
                New Member
                • Aug 2009
                • 18

                #8
                Ok, I placed this code
                Private Sub [Staff1]_LostFocus()

                Me.Parent![<SFrm_Staff2>].Form![Staff2].SetFocus

                End Sub

                The Field that I am trying to tab to tab to is [Staff2] in the SubForm SFrm_Staff2

                What am I doing wrong? When I tab the first time nothing happens. Hit tab a 2nd time and I get the error message, can't find the Field <SFrm_Staff2> referred to in your expression.

                Comment

                • ajalwaysus
                  Recognized Expert Contributor
                  • Jul 2009
                  • 266

                  #9
                  Try this:
                  Code:
                  Private Sub [Staff1]_LostFocus()
                     Me.Parent![SFrm_Staff2].Form![Staff2].SetFocus
                  End Sub
                  no "<" or ">" around the form name, ADezii was doing it for clarification.

                  -AJ

                  Comment

                  • pld60
                    New Member
                    • Aug 2009
                    • 18

                    #10
                    Thanks for everyones help but it is still not working. Now it does nothing. No error message.

                    Comment

                    • ADezii
                      Recognized Expert Expert
                      • Apr 2006
                      • 8834

                      #11
                      Originally posted by pld60
                      Thanks for everyones help but it is still not working. Now it does nothing. No error message.
                      Try a change in syntax:
                      Code:
                      Forms!<MainForm Name>![SFrm_Staff2].Form![Staff2].SetFocus

                      Comment

                      • FishVal
                        Recognized Expert Specialist
                        • Jun 2007
                        • 2656

                        #12
                        Try to set focus to a control on subform in two steps:
                        first setting focus to subform itself
                        then setting focus to the desired control on subform's form.

                        Comment

                        • pld60
                          New Member
                          • Aug 2009
                          • 18

                          #13
                          Thanks to everyone for your help. FishVal had it. This is what worked

                          [Forms]![FORM 1].[SFrm_Res2].SetFocus
                          [Forms]![FORM 1].[SFrm_Res2].[Form].[Resident2].SetFocus

                          Now is there any way to have the subforms update tables only after I click the save button on the main form?
                          Last edited by pld60; Aug 31 '09, 07:46 PM. Reason: typo

                          Comment

                          • ADezii
                            Recognized Expert Expert
                            • Apr 2006
                            • 8834

                            #14
                            Originally posted by FishVal
                            Try to set focus to a control on subform in two steps:
                            first setting focus to subform itself
                            then setting focus to the desired control on subform's form.
                            Nice work, FishVal, way to come through!

                            Comment

                            Working...