• Synchronize between ComboBox & TextBox

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Synchronize between ComboBox & TextBox

    Author
    Topic
    #461553

    The Screenshot shows a combobox and two textboxes in Design View.
    Only one table is involved, namely, tblCategory.
    tblCategory contains: CategoryID (autonum), Category, CategoryDesc.
    The unbound combobox contains two columns: CategoryID (hidden) and Category.
    The unbound combobox allows a user to select a Category.
    When the user select, say, “Access 2007”, I want the two textboxes on the right to display the corresponding Category and CategoryDesc. That requires the synchronization between the combobox and the 2 textboxes.
    The 2nd screenshot below shows no synchronization.
    Question: How to synchronize the combobox and the 2 textboxes?
    Thanks.
    Armstrong

    Viewing 1 reply thread
    Author
    Replies
    • #1171537

      The Screenshot shows a combobox and two textboxes in Design View.
      Only one table is involved, namely, tblCategory.
      tblCategory contains: CategoryID (autonum), Category, CategoryDesc.
      The unbound combobox contains two columns: CategoryID (hidden) and Category.
      The unbound combobox allows a user to select a Category.
      When the user select, say, “Access 2007”, I want the two textboxes on the right to display the corresponding Category and CategoryDesc. That requires the synchronization between the combobox and the 2 textboxes.
      The 2nd screenshot below shows no synchronization.
      Question: How to synchronize the combobox and the 2 textboxes?
      Thanks.
      Armstrong

      I dont understand why you are doing this.
      You have tblCategory as the source of the form and the source of the combo box as well.

      Is this form meant to be a maintenance form to input Categories? If so, there’s no need for the combo box.

      I must have missed something here.

      • #1171540

        I dont understand why you are doing this.
        You have tblCategory as the source of the form and the source of the combo box as well.

        Is this form meant to be a maintenance form to input Categories? If so, there’s no need for the combo box.

        I must have missed something here.

        Patt,
        The whole picture is to allow users to select a Category. Then all books with the same Category, say Access 2007, will be displayed.
        It may seem redundant to you.
        Explanation:
        1. Some categories are quite cryptic such as SC. So a long description is required. For example, SC stands for Supreme Court.
        2. By displaying Category alone won’t display the whole possible list of categories for users to select. The combobox offers the convenience to show all categories.
        Hope this could explain my design concept.
        Armstrong

        • #1171542

          Patt,
          The whole picture is to allow users to select a Category. Then all books with the same Category, say Access 2007, will be displayed.
          It may seem redundant to you.
          Explanation:
          1. Some categories are quite cryptic such as SC. So a long description is required. For example, SC stands for Supreme Court.
          2. By displaying Category alone won’t display the whole possible list of categories for users to select. The combobox offers the convenience to show all categories.
          Hope this could explain my design concept.
          Armstrong

          I still dont understand what you want, but why dont you put all 3 fields in the combo box with the CategoryID as invisble.
          In the AfterUpdate event of the combo box you would populate the text fields viz:
          TextShort = CmbCategory.Column(1)
          TextLong = CmbCategory.Column(2)

    • #1171546

      Since the combo box already displays the Category field, you don’t need a text box that also displays it. To display the CategoryDesc, you could add this field to the Row Source of the combo box, as suggested by patt, and create a text box with control source =cmbCategory.Column(2) where cmbCategory is the name of the combo box. You don’t need to use code for this.

      Note: columns of a combo box or list box are numbered starting at 0, so Column(0) is the first column, Column(1) is the second column etc.

      • #1171548

        Since the combo box already displays the Category field, you don’t need a text box that also displays it. To display the CategoryDesc, you could add this field to the Row Source of the combo box, as suggested by patt, and create a text box with control source =cmbCategory.Column(2) where cmbCategory is the name of the combo box. You don’t need to use code for this.

        Note: columns of a combo box or list box are numbered starting at 0, so Column(0) is the first column, Column(1) is the second column etc.

        Hi Hans,
        This exercise is merely help me grasp the technique to sychronize multiple textboxes in a form.
        The reason behind the textboxes bound to the fields is editabilty.
        By the combox selection, the user may not like how the Category and/or CategoryDesc was entered. So now the user has a chance to change it.

        Let me rephrase the question:
        If a user select a different Category in the combobox, the 2 textboxes should be updated accordingly. How? Should I use requery? It doesn’t seem to work. The main question here, after selecting another Category, the 2 textboxes remain the same. To be precise, it always shows the content of the 1st record in the table. The cursor/record point didn’t change.

        Armstrong

        • #1171551

          If you want the text boxes to remain editable, you should use patt’s suggestion:
          – Create unbound text boxes for Category and CategoryDesc
          – Put code in the After Update event of the combo box to update the text boxes.

    Viewing 1 reply thread
    Reply To: Synchronize between ComboBox & TextBox

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: