Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Attached Images Attached Images

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='armsys' post='786775' date='30-Jul-2009 14:32']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[/quote]
    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.

  3. #3
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='patt' post='786780' date='30-Jul-2009 12:12']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.[/quote]
    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

  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='armsys' post='786783' date='30-Jul-2009 15:43']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[/quote]
    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)

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

  6. #6
    3 Star Lounger
    Join Date
    Mar 2009
    Location
    Hong Kong
    Posts
    359
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='786789' date='30-Jul-2009 14:02']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.[/quote]
    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

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •