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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cmobobox.dropdown onChange problem 1

Status
Not open for further replies.

egrant

Programmer
Mar 6, 2003
42
AU
Hi All,

I am having a quick problem that I was hoping someone could assist me with. I have been searching through the Tek-Tips site for about an hour now and I have not found anything to what I need.

I have a combobox that has an AfterUpdate function that find data on my form based on the record that I choose. You know the basic ComboBox wizard code. I also have a dropdown command for this combo box on the 'OnChange' event. The problem is that when I use my mouse to select the item in the combo box AFTER I have serched using the dropdown via the keyboard, the dropdown list will not go away. I beleive this is becuase I told it to drop down on the 'OnChange' event, and it is constently changing therefore constantly dropping down.

I am not sure what event to put this under. I was also wondering if there is an 'anti' dropdown command to do the opposite.

It would be great if someone could help out,

Thanks,

Emma
 
Emma,

Try putting the combo dropdown method on the OnGotFocus event of the combo box NOT on the OnChange event. That should limit it to occuring only when you move into the control.



Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Thanks but that kinda eliminates the reason for the drop down box.

The form opens with the ComboBox having the focus. The reason that I put it OnChange is so as the user is typing it searches through the list of data while it is dropped down. The data is a list of customers, therefore some customers are going to have the same name, so the user wants to be able to view what the combo box is listing while they type the name they are looking for.

Aggh I am so stuck!

Thanks for your ideas so far Steve

Emma
 
Alas, all is not lost Emma. Check out the Auto Expand property of the combo. Make sure this is set to YES; this lets you see what the list options are as you type.

Hope this is closer to the mark; otherwise I could be missing the plot :),

Regards


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
AutoExpand is on. This works fine if I use the keyboard, the way that I have set it up. It's just the mouse that's the pain.

The AutoExpand lets me see the text as I am typing it in the ComboBox itself. But I use the dropdown method so the user can see the entire listing of closely matched names.

So I put this on OnChange so when ever they type the listing appears. If I put it on OnGotFocus it will only appear the first second the control has the focus.

This combo box is a more of a search control. Meaning that the user try to type in nearly any combination over and over again until they find what they are looking for.

Is there a way to reverse a dropdown method? setting it false or something.


Thanks,

Emma

~Customers drive me crazy, Bosses want the world... if I was building this database for myself it would have been finished years ago!
 
Emma,
I do know what you're trying to do though, I think its becoming too complex. Here's some extra info which you may be able to use:

the
[tt]
SendKeys "{F4}"
[/tt]

command can be used to simulate sending an F4 keystroke to the application. If the combo has the focus, and is open, this should close the dropdown; otherwise it should act as a toggle. Note that you can put a ", True" or a ", False" after the "{F4}" as an optional argument. Not sure if this will make any difference, but its another tool in your kitbag, and may be useful for closing the combo.



Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
THANK YOU!!!


It worked!

I simply put the SendKeys "{F4}" function AFTER the AfterUpdate function that places the value on the form.

SWEET... I am gonna write my code so I can help other out if they come accross the same problem.

'This makes the combo dropdown as you type. Be sure that AutoExpand is set to true to get a better result.


Private Sub Combo123_Change()
Combo123.Dropdown
End Sub


Then run the code that places data on your form based on the combo box value...


Private Sub Combo123_AfterUpdate()
On Error GoTo Err_Combo123_AfterUpdate

' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[CUSTOMER_ID] = " & str(Me![Combo123])
Me.Bookmark = rs.Bookmark


SendKeys "{F4}"
'ends the DropDown command


Exit_Combo123_AfterUpdate:
Exit Sub

Err_Combo123_AfterUpdate:
Resume Exit_Combo123_AfterUpdate

End Sub


Thanks again Steve,

Emma


~Customers drive me crazy, Bosses want the world... if I was building this database for myself it would have been finished years ago!
 
Pleasure Emma; glad you got it sorted out,

Regards,


Steve Lewy
Solutions Developer
steve@lewycomputing.com.au
(dont cut corners or you'll go round in circles)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top