?
Solved

Combo box mouse problems

Posted on 2002-05-31
6
Medium Priority
?
141 Views
Last Modified: 2010-05-02
Ive written code to make a combo box autoselect list items base on a series of key presses (e.g. 'n','a','n' would autoselect 'nancy' from a list which included 'neal',nadine,'ned'...etc.....
The algorithm detects the enter key to select the current text from the
combo box and populate a textbox with that data. (remember partial matches populate the combo box so enter is like the verifier saying 'this is the one I want'. THe problem I have is that I still want to be able to detect when the user selects something from the combobox's drop down using a mouse. Being that the mouse populates the combo box's text without any event other than "click" I am having trouble telling the difference between when the combobox is in an intermediate selection (user has only partially typed his item), and when the user has selected an item from the combo-box's drop down with the mouse.
here is the code which does this.
----------------------------------------------------------------------
Private Sub cmbProcedures_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next

strkey = KeyCode
strshift = Shift

If strkey = 40 And Shift = 4 Then
GoTo line_go
Else
If Not (strkey = 13) Then
Exit Sub
End If
End If

line_go:
strindex = cmbProcedures.ListIndex
cmbProcedures.Text = cmbProcedures.List(strindex)
End Sub
------------------------------------------------------------------------
Private Sub cmbProcedures_KeyUp(KeyCode As Integer, Shift As Integer)
Debug.Print "KEYCODE:" & KeyCode

If KeyCode = 13 Then
Procs
val = "" 
Exit Sub
End If

val = Replace(val, Chr(16), "")
val = val & LCase(Chr(KeyCode))

If KeyCode = 8 Then
val = "" 
Exit Sub
End If

For I = 0 To cmbProcedures.ListCount - 1
If (InStr(1, LCase(cmbProcedures.List(I)), val) = 1) Then
cmbProcedures.Text = cmbProcedures.List(I)
Exit Sub
End If
Next I
End Sub
------------------------------------------------------------------------
Private Sub cmbProcedures_LostFocus()
val = "" 'module level variable
End Sub
------------------------------------------------------------------------
0
Comment
Question by:mccainz2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7047833
In combobox change event?
0
 
LVL 5

Author Comment

by:mccainz2
ID: 7047865
change would fire with both the mouse and the keypress in my case...need a way to differentiate which one caused the change.
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 300 total points
ID: 7048281
Using a boolean flag variable could help.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Author Comment

by:mccainz2
ID: 7055383
yup ended up setting a boolean variable on the combobox dropdown event and flipping it on the keydown event.Worked like a charm.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7056146
Glad to hear it!
Just for clarification, if "Worked like a charm", why did you punish me with "B" grade?
Cheers
0
 
LVL 5

Author Comment

by:mccainz2
ID: 7056492
Punish with a B grade???
Sheesh. AN A answer would have included more detail regarding events that could possibly (and correctly ie(not combo change)) be monitired to toggle the boolean.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question