Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Disable one combo box based on value of another (2000-SR1)

    I have a form set for continuous forms for the client to place multiple orders of different items, some of which color or quantity need to be specified. So combo box ItemID specifies the item, combo box Color and combo box Qty specify the other details. I would like to deactivate the "color" and/or "qty" combo boxes based on the value of the ItemID combo box. For example, if ItemID is "1", then "color" is not to be an option, and "qty" needs to be automatically entered as "1". Or, if ItemID="3", the color is not an option...
    Does that make sense?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Disable one combo box based on value of another (2000-SR1)

    You can use conditional formatting to enable/disable a control:

    - Open the form in design view.

    - Select the Color combo box.
    - Select Format | Conditional Formatting...
    - Under Condition 1, select Expression Is from the dropdown list.
    - Enter the expression
    <code>
    [ItemID]=1 Or [ItemID]=3
    </code>
    in the box next to it.
    - Click the Enabled button to turn it off (it is the rightmost button under the expression box).
    - Click OK.

    - Create an After Update event procedure for the ItemID combo box:

    Private Sub ItemID_AfterUpdate()
    If Me.ItemID = 1 Then
    Me.Qty = 1
    End If
    End Sub

  3. #3
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable one combo box based on value of anothe

    Works like a charm...how do I get it to open the next record automatically following the entry of "1" in the quantity combo box? (As it is, the focus goes to that combo box when I hit "Tab"...I think I would like it to go to the next (new) record when I hit "Tab".)

    Thanks so much,
    Warren

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Disable one combo box based on value of anothe

    For example:

    Private Sub ItemID_AfterUpdate()
    If Me.ItemID = 1 Then
    Me.Qty = 1
    RunCommand acCmdRecordsGoToNext
    End If
    End Sub

  5. #5
    2 Star Lounger
    Join Date
    Jan 2005
    Location
    Wichita, Kansas, USA
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Disable one combo box based on value of anothe

    Thanks! Works great....

Posting Permissions

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