Results 1 to 4 of 4

Thread: [RESOLVED] How to autocomplete TextBoxs? (using ADODB and Access) [VB6]

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    9

    Resolved [RESOLVED] How to autocomplete TextBoxs? (using ADODB and Access) [VB6]

    Hi people, I'm new here and you've already solved a doubt of mine once. Now I'm raising another question, and it's just like the tittle says:

    How should I do to make an autocomplete when I write a number in a TextBox and another TextBox get filled with the correct data from the Table which I'm calling from?

    An image to explain a bit my case:

    Name:  autocompletar.jpg
Views: 544
Size:  22.2 KB

    As you can see in the screenshot, I wrote the numer "1" in the first TextBox, then I had to write "Martillo" in the next TextBox... Now I want that that TextBox to get filled automatically with "Martillo" so I don't have to write it again...

    Hope you understand my way to speak, I'm not so good in english... Thanks!!!

    Regards!

  2. #2
    New Member
    Join Date
    Mar 2007
    Location
    Jeddah
    Posts
    13

    Re: How to autocomplete TextBoxs? (using ADODB and Access) [VB6]

    Just call the recordset
    -----------------------------
    put this code in textbox1_change event

    --------------------------------------------------------
    dim getnames as recordset
    set getnames=c.openrecordset("select <namefield from <tablename> where <idfield>=' " & textbox1.text & " ' ")
    if getnames.recordcount>0 then
    textbox2.text=getnames!namefiled
    else
    textbox2.text="No Data"
    endif




    ' I hope you understand the concept
    <[email protected]>

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2015
    Posts
    9

    Re: How to autocomplete TextBoxs? (using ADODB and Access) [VB6]

    Quote Originally Posted by hameed View Post
    Just call the recordset
    -----------------------------
    put this code in textbox1_change event

    --------------------------------------------------------
    dim getnames as recordset
    set getnames=c.openrecordset("select <namefield from <tablename> where <idfield>=' " & textbox1.text & " ' ")
    if getnames.recordcount>0 then
    textbox2.text=getnames!namefiled
    else
    textbox2.text="No Data"
    endif




    ' I hope you understand the concept
    <[email protected]>
    Quote Originally Posted by hameed View Post
    Just call the recordset
    -----------------------------
    put this code in textbox1_change event

    --------------------------------------------------------
    dim getnames as recordset
    set getnames=c.openrecordset("select <namefield from <tablename> where <idfield>=' " & textbox1.text & " ' ")
    if getnames.recordcount>0 then
    textbox2.text=getnames!namefiled
    else
    textbox2.text="No Data"
    endif
    Ok, I understood what you said so I did this:

    Code:
    Dim conexion As New ADODB.Connection
    Dim getnames As New ADODB.Recordset
    
    Private Sub Text2_Change()
    
    Set getnames = New ADODB.Recordset
    If Not Text2.Text = "" Then
    getnames.Open "SELECT Herramienta FROM Herramientas WHERE idHerramienta=" & Text2.Text & "", conexion, adOpenStatic, adLockOptimistic
        If getnames.RecordCount > 0 Then
        Text3.Text = getnames!Herramienta
        Else
        Text3.Text = "No Data"
        End If
    End If
    End Sub
    and it works perfectly, thank you very much for your help!!!!

    best regards

  4. #4
    New Member
    Join Date
    Mar 2007
    Location
    Jeddah
    Posts
    13

    Re: How to autocomplete TextBoxs? (using ADODB and Access) [VB6]

    you are welcome ,
    any time you have any doubts pls contact, i will try to solve if its in my knowledge.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width