Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling Combo Box functionality

Status
Not open for further replies.

aclambert

Technical User
Oct 5, 2008
8
GB
Hello

just wondering if anybody has any ideas on this.

I have a form (containing a sub-form) which lists all order lines from a simple ordering system. On this form I have several unbound combo boxes to filter the items on the form by order number, customer name, sales assistant name and part number. The subform contains all the order line info.

I only want to choose one combo box at a time. If I make a choice from one combo, I would like it to clear the selections in the others.

Thanks for your help.

Cheers
Aaron
 
Maybe in the click event, you can use the .Clear method on all the other combo boxes?

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 
Oops - maybe the change event?

"Don't be irreplaceable. If you can't be replaced, you can't be promoted."
 

Code:
Private Sub ComboBoxOne_AfterUpdate()
 If Not IsNull(Me.ComboBoxOne) Then
   Me.ComboBoxTwo = Null
   Me.ComboBoxThree = Null
 End If
End Sub

Private Sub ComboBoxTwo_AfterUpdate()
If Not IsNull(Me.ComboBoxTwo) Then
   Me.ComboBoxOne = Null
   Me.ComboBoxThree = Null
 End If
End Sub

Private Sub ComboBoxThree_AfterUpdate()
If Not IsNull(Me.ComboBoxThree) Then
   Me.ComboBoxOne = Null
   Me.ComboBoxTwo = Null
 End If
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
How are ya aclambert . . .

In [blue]form design[/blue] view put a question mark [blue]?[/blue] in the [blue]Tag[/blue] property of the 4 comboboxes ([red]no quotations please![/red]).

Copy/paste the following routine to the code module of the form or subform where the comboboxes reside:
Code:
[blue]Private Sub ClrCbx()
   Dim ctl As Control
   
   For Each ctl In Me.Controls
      If ctl.Tag = "?" And ctl.Name <> Screen.ActiveControl.Name Then ctl = Null
   Next
End Sub[/blue]
Then in the [blue]After Update[/blue] event of each combobox, copy/paste the following line:
Code:
[blue]   Call ClrCbx[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top