By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,984 Members | 997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,984 IT Pros & Developers. It's quick & easy.

VB 6.0 Auotfiltering in textbox

P: 11
HI...Im researching for how to auto filter the text box while im typing inside it (ex. I type A in the VB textbox and all records that have letter A will appear dropdown and as I proceed typing Am all records that have Am will appear dropdown) plzzzzzzzzzzzzzz..... any one can give me some code how to do this in my VB 6.0 project....Im using sql as my database!



I will be thankful if any one will reply!thnx....
Sep 3 '07 #1
Share this Question
Share on Google+
11 Replies


hariharanmca
100+
P: 1,977
HI...Im researching for how to auto filter the text box while im typing inside it (ex. I type A in the VB textbox and all records that have letter A will appear dropdown and as I proceed typing Am all records that have Am will appear dropdown) plzzzzzzzzzzzzzz..... any one can give me some code how to do this in my VB 6.0 project....Im using sql as my database!



I will be thankful if any one will reply!thnx....

Use the query like

Expand|Select|Wrap|Line Numbers
  1. strSql = "Select <Field Names> from <Table Name> where <Search Field> like '" & strSearchText & "%'"
Sep 3 '07 #2

Expert 5K+
P: 8,434
... auto filter the text box while im typing inside it (ex. I type A in the VB textbox and all records that have letter A will appear dropdown and as I proceed typing Am ...
I'm guessing you must be referring to a listbox or something of that sort? A textbox can only display one thing at a time.
Sep 4 '07 #3

QVeen72
Expert 100+
P: 1,445
Hi,

use a ComboBox, It can Act as both TextBox and a ListBox. Write the Code in KeyPresss event, to populate the Combo..

REgards
Veena
Sep 4 '07 #4

hariharanmca
100+
P: 1,977
Combo Box is not good for huge list because that will not automatically show the list and we should add 3 to 30 items (Static Data).

We have to use programmatically adding items in ‘List Box’ or ‘List view’ with ‘Text Box’ combination.
Sep 4 '07 #5

QVeen72
Expert 100+
P: 1,445
Hi hari,

what is this " we should add 3 to 30 items (Static Data)"....?
Why do we need to add Static Data...?

I always prefer TextBox + ListBox Combination with "Sorted" property of the ListBox =True. Since he said he wants to type, I suggested ComboBox


REgards
Veena
Sep 4 '07 #6

P: 10
HI...Im researching for how to auto filter the text box while im typing inside it (ex. I type A in the VB textbox and all records that have letter A will appear dropdown and as I proceed typing Am all records that have Am will appear dropdown) plzzzzzzzzzzzzzz..... any one can give me some code how to do this in my VB 6.0 project....Im using sql as my database!



I will be thankful if any one will reply!thnx....

Hey friend
use a frame named 'framepartdet'
put MSFlex grid named 'searchgrid' on 'framepartdet' with three columns, fixed rows 2



Expand|Select|Wrap|Line Numbers
  1. Private Sub txtcode_Change()    'event
  2. Dim i As Integer
  3.   If rsstock.State = adStateOpen Then rsstock.Close
  4.   Dim ccode As String
  5.  If txtcode.Text = "" Then   ' text box value
  6.  framepartdet.Visible = False
  7.  Exit Sub
  8.  End If
  9.     ccode = Trim(txtcode.Text)
  10.     rsstock.Open "select distinct code,name from table where field like '" & ccode & "%' ", cn, adOpenDynamic, adLockOptimistic
  11.    If Not rsstock.EOF And Not rsstock.BOF Then
  12.       framepartdet.Visible = true
  13.       rsstock.MoveFirst
  14.       i = 0
  15.       searchgrid.Rows = 1
  16.       Do While Not rsstock.EOF
  17.          With searchgrid
  18.             .TextMatrix(i, 0) = i+1  
  19.             .TextMatrix(i, 1) = "" & rsstock.Fields(0)
  20.             .TextMatrix(i, 2) = "" & rsstock.Fields(1)
  21.                        i = i + 1
  22.             .Rows = .Rows + 1
  23.              End With
  24.         rsstock.MoveNext
  25.        Loop
  26.    Else
  27.     framepartdet.Visible = False
  28.     End If
  29.    rsstock.Close   
  30. End Sub
* link removed *

Sep 4 '07 #7

hariharanmca
100+
P: 1,977
Hi hari,

what is this " we should add 3 to 30 items (Static Data)"....?
Why do we need to add Static Data...?

I always prefer TextBox + ListBox Combination with "Sorted" property of the ListBox =True. Since he said he wants to type, I sujjested ComboBox


REgards
Veena
we should add 3 to 30 items (Static Data)"....?
That is not exact count (that is approximate).
Static Data - I mean which will change the list index during key press or key up event.
Sep 4 '07 #8

P: 11
thanks!for your reply but i can't get it...can u plz instruct me the step by step method on how can I make a textbox searching in vb6 using my sql database!sorry for being slow...Im only a noob in VB6...
Sep 12 '07 #9

P: 11
Hi hari,

what is this " we should add 3 to 30 items (Static Data)"....?
Why do we need to add Static Data...?

I always prefer TextBox + ListBox Combination with "Sorted" property of the ListBox =True. Since he said he wants to type, I suggested ComboBox


REgards
Veena

Hi QVeen72
tnx for the response...can you teach me how to use combobox in filtering?ex.when I type A all names starting A will appear and if i type Ab all names with Ab appear and the names with the letter A but without b will disappear!how can I do that?
Sep 12 '07 #10

P: 11
tnx for the response...can you teach me how to use combobox in filtering?ex.when I type A all names starting A will appear and if i type Ab all names with Ab appear and the names with the letter A but without b will disappear!how can I do that?
Sep 12 '07 #11

P: 11
Hey friend
use a frame named 'framepartdet'
put MSFlex grid named 'searchgrid' on 'framepartdet' with three columns, fixed rows 2



Expand|Select|Wrap|Line Numbers
  1. Private Sub txtcode_Change()    'event
  2. Dim i As Integer
  3.   If rsstock.State = adStateOpen Then rsstock.Close
  4.   Dim ccode As String
  5.  If txtcode.Text = "" Then   ' text box value
  6.  framepartdet.Visible = False
  7.  Exit Sub
  8.  End If
  9.     ccode = Trim(txtcode.Text)
  10.     rsstock.Open "select distinct code,name from table where field like '" & ccode & "%' ", cn, adOpenDynamic, adLockOptimistic
  11.    If Not rsstock.EOF And Not rsstock.BOF Then
  12.       framepartdet.Visible = true
  13.       rsstock.MoveFirst
  14.       i = 0
  15.       searchgrid.Rows = 1
  16.       Do While Not rsstock.EOF
  17.          With searchgrid
  18.             .TextMatrix(i, 0) = i+1  
  19.             .TextMatrix(i, 1) = "" & rsstock.Fields(0)
  20.             .TextMatrix(i, 2) = "" & rsstock.Fields(1)
  21.                        i = i + 1
  22.             .Rows = .Rows + 1
  23.              End With
  24.         rsstock.MoveNext
  25.        Loop
  26.    Else
  27.     framepartdet.Visible = False
  28.     End If
  29.    rsstock.Close   
  30. End Sub
* link removed *



Hi syamas

tnx for the response...can you teach me how to use combobox in filtering?ex.when I type A all names starting A will appear and if i type Ab all names with Ab appear and the names with the letter A but without b will disappear!how can I do that?
Sep 12 '07 #12

Post your reply

Sign in to post your reply or Sign up for a free account.