1 Attachment(s)
[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:
Attachment 128371
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!:wave:
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]>
Re: How to autocomplete TextBoxs? (using ADODB and Access) [VB6]
Quote:
Originally Posted by
hameed
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
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
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.