Set focus but record not selected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • donraf
    New Member
    • Mar 2023
    • 1

    Set focus but record not selected

    I have a main form (Orders), a subform (OrderDetails) and a separate form (Products).

    The OrderDetails is a child form of Orders.
    Products form is opened via a button on Orders.

    There is an image of the product on the product form that on the On_Click event loads the product into a combo box on the subform OrderDetails.
    I use SetFocus but that only sets the focus to the combo box but does not actually record the selection.
    I have to click the drop down and select the product from the list again to record it.

    How can I actaully select the record not just set the focus.

    Thank you for your help.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    Hi Donraf.

    Welcome to Bytes.com.

    I haven't played with this in a while but I believe that the way you select an item within a ComboBox from your code is to set the .Value of the ComboBox to the value that matches the product. This changes based on which column is treated as the value column, but generally in such situations it's either the name, description or ID column.

    I believe there's also a .Dropdown() method for ComboBoxes so you can even get it to drop down for the user if you really want to draw their attention to it ;-)

    Comment

    Working...