Here is a simple example.... Create a new form and add one combo to it and paste the entire code below it to test....
Hope this helps...Code:'~~> Needs 1 Form, 1 Combobox Option Explicit '~~> API Declarations Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _ (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) _ As Long '~~> API Constants Private Const CB_SELECTSTRING = &H14D Private Sub Combo1_KeyPress(KeyAscii As Integer) Dim Ret As Long Dim sText As String With Combo1 If Not (KeyAscii = vbKeyBack Or KeyAscii = vbKeyEscape Or _ KeyAscii = vbKeyReturn) Then If .SelLength > 0 Then sText = Left$(.Text, .SelStart) & Chr$(KeyAscii) Else sText = .Text & Chr$(KeyAscii) End If Ret = SendMessage(.hwnd, CB_SELECTSTRING, -1, sText) If Ret <> -1 Then .SelStart = Len(sText) .SelLength = Len(.Text) - .SelStart + 1 Else .Text = sText .SelStart = Len(sText) + 1 End If KeyAscii = 0 End If End With End Sub Private Sub Form_Load() '~~> Just a sample. You can add items from your table Combo1.Clear With Combo1 .AddItem "koolsid" .AddItem "hack" .AddItem "vbfnewcomer" .AddItem "luca" .AddItem "let me in" .AddItem "blah blah" .AddItem "kool" .AddItem "hacker" .AddItem "Etc..." End With End Sub




Reply With Quote