Solved

drop-down combo box

Posted on 1998-08-30
4
243 Views
Last Modified: 2012-05-04
How can I add a typomatic feature to a drop-down combo box?
0
Comment
Question by:gcassel
  • 2
4 Comments
 
LVL 4

Expert Comment

by:mcix
ID: 1431936
What does typomatic mean?
0
 
LVL 9

Accepted Solution

by:
Dalin earned 100 total points
ID: 1431937
gcassel,
Try this code. Let me know if this is not what you want.
Regards
Dalin

'In the form's General Declaration area, add:
Declare Function SendMessage Lib "User32" Alias _
  "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
  ByVal wParam As Long, lParam As Any) As Long

Const CB_ERR = -1
Const CB_FINDSTRING = &H14C

'Add the sub

Sub sMatchEntry(cbo As ComboBox, KeyAscii As Integer)
  Dim sBuffer As String
  Dim lRetVal As Long

  sBuffer = Left(cbo.Text, cbo.SelStart) & Chr(KeyAscii)
  lRetVal = SendMessage((cbo.hWnd), CB_FINDSTRING, _
  -1, ByVal sBuffer)
  If lRetVal <> CB_ERR Then
    With cbo
      .ListIndex = lRetVal
      .Text = .List(lRetVal)
      .SelStart = Len(sBuffer)
      .SelLength = Len(.Text)
    End With
    KeyAscii = 0
  End If
End Sub

' in the KeyPress Event add:

Private Sub Combo1_KeyPress(KeyAscii As Integer)
  sMatchEntry Combo1, KeyAscii
End Sub
0
 

Author Comment

by:gcassel
ID: 1431938
Dalin,
   Thanks. I tried the code but no matter what letter I type I get no response.  I can still though select by clicking on the down arrow and selecting from the drop-down combo box list.  I  however want to be able to use the typomatic feature since my list is rather large.  Any other suggestions on what I might be doing wrong.
Thanks,
Gary
0
 

Author Comment

by:gcassel
ID: 1431939
Dalin,
In looking at the code further each time I enter a key SendMessage returns -1
lRetVal=SendMessage((cbo.hwnd),CB_FINDSTRING, -1, ByVal sBuffer)
  -1                  740          332                     "k"


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now