PDA

Click to See Complete Forum and Search --> : Combo matching on more than on character


jbuck
Dec 27th, 1999, 05:01 AM
i have a number of combo boxes from diferrent tables on a form that I'm using ADO to populate and Then depending on the selection by the user, I write the value to the current Table. I would like to be able to cut down the search as the person starts keying in the data. For example as a person keys in "J" cutout everything that doesn't start with "J", then if he keys in "JO" cut out everything that doesn't start with "JO" and so on. Thanks

Gimpster
Dec 27th, 1999, 06:01 AM
Try this code, I have this set up where this code is in the text1_Change event, but you may be able to play around with it a bit to get it to work with Combo boxes.

list1.ListIndex = SendMessage(listTables.hWnd, LB_FINDSTRING, -1, ByVal txtViewTable.Text)

Good luck, and let me know what you changed to get it to work with Combo boxes.

------------------
Ryan
cornelsen@hotmail.com
ICQ (http://www.ICQ.com)# 47799046



[This message has been edited by Gimpster (edited 12-27-1999).]

Clunietp
Dec 27th, 1999, 09:28 AM
Gimpster's code requires an API declaration.... add this to a module

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Let us know if this is the wrong one, gimpster

Tom

Ruchi
Dec 27th, 1999, 12:45 PM
You can use SendMessageByString API to the window handle of the Combo Box. Assuming that you have the ComboBox's window handle.


Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Const CB_FINDSTRING = &H14C

moCbo.ListIndex = SendMessageByString(moCbo.hwnd, CB_FINDSTRING, -1, txtViewTable.Text)



Ruchi

[This message has been edited by Ruchi (edited 12-28-1999).]