Using a text box to search a listbox

E

EAB1977

Hi everyone,

I found some code in Microsofts Knowledge Base (http://
support.microsoft.com/kb/161161/en-us) on how to use a textbox to
search on a listbox, but when I go to add a letter in a listbox, I get
a overflow error.

Can anyone tell me what is wrong with this? Or can this not be done?

Option Compare Database

' Enter the Declare statement on one single line:
Private Declare Function SendMessage Lib "User" (ByVal hwnd As
Integer, ByVal wMsg As Integer, ByVal wp As Integer, lp As Any) As
Long
Const WM_USER = &H400
Const LB_FINDSTRING = (WM_USER + 16)

Sub Form_Load()
List1.RowSourceType = "Value List"
List1.AddItem "Apples"
List1.AddItem "Banana"
List1.AddItem "Bread"
List1.AddItem "Break"
'SELECT * FROM tblActiveDirectory WHERE
(((tblActiveDirectory.Email) Is Not Null));
End Sub

Private Sub Text1_Change()
' The following code should be on one single line:
List1.ListIndex = SendMessage(Form.hwnd, LB_FINDSTRING, -1, ByVal
CStr(Text1.Text))
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top