troubleshooting Question

Remove Item from combobox after being selected.

Avatar of skull52
skull52Flag for United States of America asked on
Microsoft AccessVBASQL
17 Comments1 Solution87 ViewsLast Modified:
I have a combo box (cboAttrb) (Attribute) that is filtered by the contents of another combo box (cboSubcat) (Subcategory) with a query. for example if cboSubcat contains "Accessory" then cboAttrib would only display the attributes assigned to that Subcategory  "Color",Style", "Etc". what I would like to have happen is when the Color attribute is selected it disappears from the list, and only Style remains. what I am currently doing on the AfterUpdate Event is if the Attribute has been selected  I do a DCount in the on the item_attrib_attribvl table with the ITEMNMBR and the ATTRIB_ID if it is > 0  I popup a message that the Attribute has already been selected.

Private Sub cboAttrb_AfterUpdate()
    If DCount("*", "item_attrib_attribvl", "(ITEMNMBR = '" & Me.txtItem & "') AND (ATTRIB_ID=  " & Me.cboAttrb & " )") > 0 Then
        MsgBox "You Have Already selected the " & Me.cboAttrb.Column(1) & " Attribute", vbOKOnly + vbCritical, "Attribute Duplication Error"
        bSaveClicked = False
        Me.cboAttrb.SetFocus
        Me.cboAttrb = Null
        Exit Sub
        ' End If
    Else
        bSaveClicked = False
        Me.cboAttribvl.Requery
    End If
End Sub
ASKER CERTIFIED SOLUTION
Mark Edwards
Chief Technology Officer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 17 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 17 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros