Is it possible to read a text box inside Subform within tabcontrol?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • poornesh K V
    New Member
    • Jan 2007
    • 3

    Is it possible to read a text box inside Subform within tabcontrol?

    This is the details:

    I have a Form : ProjectDetails

    This form is made up of a TabControl : maintabctrl1 (Say 10 pages)

    Each page has a subform : subForm1

    This subForm1 has tabcontrol : tabctl1(say 10 pages)

    now, a text box in one of the Page...

    MainForm -> Main TabControl -> Page1 > SubForm1 -> tabctl1 ->Page2 ---
    In this page i have the text box (text1)...

    How to read this text box using VBA code???
  • Megalog
    Recognized Expert Contributor
    • Sep 2007
    • 378

    #2
    Code:
    Private Sub GetValue()
    Dim strTest As String
    
    strTest = [Forms]![ProjectDetails]!subForm1.Form.Controls("text1").Value
    
    MsgBox strTest
    
    End Sub
    Easy enough.. the only thing you really had to worry about was the subform name and the control within it.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32633

      #3
      Referring to Items on a Sub-Form may help. It should have all the details in there.

      Comment

      • poornesh K V
        New Member
        • Jan 2007
        • 3

        #4
        Hi,

        Thanks for sharing the subform related topics...

        I tried all the technics quoted but no success. The problem is not just because of Subform controls, it is because of TabControls (I am not sure how tabctrl works).

        When i used the below code i got Error 2465: Form cant find the field 'Text1' refered to your expression.

        Below is the line of code:
        Code:
        strTest = Form_ProjectDetails.Governance.Form.Controls("Text1").Value
        Where->
        ProjectDetails - Main Form
        Governance - Sub Form

        I the scenario is like this:
        Main Form(ProjectDet ails) has a tab control(maintab cntl) with 17 pages.
        In every page of the main tab control i have subform (eg: Governance) and these subforms contains tab control(tabcntl 1) with more than 4 pages.

        And i have 2 text boxes each in every page of sub tab control (tabcntl1).

        Let me know how to read each one of the text boxes.
        Last edited by NeoPa; Jan 2 '10, 03:34 PM. Reason: Please use the [CODE] tags provided.

        Comment

        • ChipR
          Recognized Expert Top Contributor
          • Jul 2008
          • 1289

          #5
          You can not have 17 subforms called Governance, whether they are on separate tab pages or not. Check the actual name of the subform control.

          Comment

          • poornesh K V
            New Member
            • Jan 2007
            • 3

            #6
            Hi,
            The tab control (maintabcntl) is having 17 pages. And i have added subform control on each page. So these subform control load different forms (Created as a form). I have 17 forms like this and each form will be loaded on pages using Subform control.

            Regards,
            Poornesh

            Comment

            • ChipR
              Recognized Expert Top Contributor
              • Jul 2008
              • 1289

              #7
              Given your example, have you tried:
              Code:
              strTest = Form_ProjectDetails!Governance.Form![Text 1]

              Comment

              • NeoPa
                Recognized Expert Moderator MVP
                • Oct 2006
                • 32633

                #8
                Originally posted by ChipR
                You can not have 17 subforms called Governance, whether they are on separate tab pages or not. Check the actual name of the subform control.
                Chip's comment indicates you have not grasped what was explained in the linked article (see post #3). There is quite a difference between the SubForm control, and the form that is contained therein. The control is correctly called a SubForm. The contained form is not. If you can understand what's in the linked article it should help you both to understand your issue, as well as describe it more clearly in here for people to respond to. I suggest you visit it again.

                Comment

                Working...