Solved

drop-down combo box

Posted on 1998-08-30
4
245 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…

820 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