combo box not showing selected item..

G

Guest

hi,
i'm using the mousedown event on a an Office Excel 2003 user form combobox,
to trigger ADO calls to Access to populate the dropdown. I also clear out the
combobox each time, so the list doesn't duplicate each time it's clicked.
However, if mouse released (up), then selects an item and clicks (down), the
selected item does not show in combobox - it's always the 1st item in list
that shows.
If I do not release mouse (up), and select from list, it works fine. It's
like the mousedown event executes again when i select the item.

any idea as to how I could handle this? i'm pretty new to working with
mousedown/up events.

thanks!
Don
 
G

Guest

Hi,
Not sure i get but:

- You could track whether an event occurs because of a direct user action or
because of your code has triggered some control's event. Set a variable
called UserTrigger as boolean.
- use it to manage when the code within an event should be executed:
- if the event is triggered because you are modifying things through code
then don't execute
- if the event is triggered because of actions from the user then do
execute

Private Sub ComboBox1_MouseUp( ... )
if UserTriggered then
'Start by setting UserTriggered to False
'Process code here which changes controls
'... (1)
'Reset UserTriggered to True
End Sub

eg, if you chancge a control in the above code at the leve of (1) (see
above) and this action triggers another control's _Change event. At (1), the
code jumps to that other control 's _Change code; however you know
UserTriggered is False, so avoid processing code in a If-Then.

I hope i was clear enough, ... not sure about that... :)
 

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

Top