Solved

Typing in a texbox and search for char!!!!

Posted on 2001-06-06
10
174 Views
Last Modified: 2010-05-02
Hi,
I need the code when i type some text in a textbox like "So" that the textbox autom. search the rest like "sof" of "soft" i have the textbox linked to a database.

Thanks
0
Comment
Question by:pfjvisser
  • 5
  • 4
10 Comments
 
LVL 18

Expert Comment

by:deighton
ID: 6159683
Do you mean that the textbox will 'auto complete' (such as an address in EE)?
0
 

Author Comment

by:pfjvisser
ID: 6159783
yes plz, do you no how to do it,

The text2.text is linked to a row in a database called CD NAAM.

0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6160542
do you want to scan the database for every keysroke entered? what if no match is found?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:pfjvisser
ID: 6160603
Yes Maxim10553 i want to scan the ROW in the database scaned and if notfound then let me compleet the word i want to type,
0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6160619
alright i have coded something like this before but not when the textbox is linked, let me see what i can come up with, gotta to do something right now, will get back to you though
0
 

Author Comment

by:pfjvisser
ID: 6160631
Oke thanks,Maxim10553
0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6165403
Here is some sample code, you need to edit it a little, create a new vb standard exe and insert a textbox in it, clear the caption so it is empty, edit the code a little, and run, should try and auto-complete your words


Option Explicit
Dim cn As New ADODB.Connection
Dim Key As Long

Private Sub Form_Load()

cn.Open ("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=C:\Temp\db1.mdb")

End Sub

Private Sub Text1_Change()

'dont go at database is backspace is hit
If Key = 8 Then Exit Sub

Dim grabbedtext As String: Dim sql As String
Dim rs As New ADODB.Recordset

grabbedtext = Trim(Text1.Text)

If grabbedtext = "" Then Exit Sub

sql = "Select term from table1 where term like '" & grabbedtext & "%'"

MsgBox sql

Set rs = cn.Execute(sql)

If rs.EOF = False Then
    Text1.Text = rs("Term")
    Text1.SelStart = Len(grabbedtext)
    Text1.SelLength = Len(Text1.Text)
Else
End If

rs.Close
Set rs = Nothing

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
Key = KeyAscii
End Sub
0
 
LVL 3

Expert Comment

by:Maxim10553
ID: 6181296
you still around?
0
 
LVL 3

Accepted Solution

by:
Maxim10553 earned 40 total points
ID: 6183039
did my code help?
0
 

Author Comment

by:pfjvisser
ID: 6283514
Yes, Sory that the answer came late. Thanks ANW.
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question