Filter by Selection by Double Clicking a Combo

  • Thread starter Thread starter scs
  • Start date Start date
S

scs

I have a continuous form that is used to enter customer visits. The
customer field is a combo box. When I pick someones name I'd like to be
able to double click on it to filter the form to only that persons record.
And then I'd like to single click on the persons name to remove the filter
by selection. I can of course just use the tool bar but I think this would
be very nice feature and I'd like to learn how to do this. Can someone show
me what the code or macro would look like?

Thanks very much.
Steve
 
the code is easy enough, but i wonder about the advisability of using
DoubleClick event - that's such a common action, people do it accidentally,
they do it without thinking, they do it to highlight a word in a control. a
single click is even more questionable - once you filter the form, you have
to remember that you can only enter the combo box control by tabbing,
because if you click into it you will remove the filter.

suggest right-click as a possible alternative, or perhaps a command button
in the form's header or footer section, which will act on the selected
record. also suggest that the same action be used to apply the filter and
remove the filter, to achieve a "toggle" effect. the following code will do
that, and should run on double-, single- or right-click of a control, or on
a command button, as

If Me.FilterOn Then
Me.FilterOn = False
Else
Me.Filter = "FieldName = '" & Me!ControlName & "'"
Me.FilterOn = True
End If

replace FieldName with the name of the customer field, and ControlName with
the name of the combobox control that's bound to the customer field (the
field and control names may be the same, of course, and that's okay.)

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top