Solved

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

Posted on 2001-06-06
10
171 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
Comment Utility
Do you mean that the textbox will 'auto complete' (such as an address in EE)?
0
 

Author Comment

by:pfjvisser
Comment Utility
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
Comment Utility
do you want to scan the database for every keysroke entered? what if no match is found?
0
 

Author Comment

by:pfjvisser
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:pfjvisser
Comment Utility
Oke thanks,Maxim10553
0
 
LVL 3

Expert Comment

by:Maxim10553
Comment Utility
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
Comment Utility
you still around?
0
 
LVL 3

Accepted Solution

by:
Maxim10553 earned 40 total points
Comment Utility
did my code help?
0
 

Author Comment

by:pfjvisser
Comment Utility
Yes, Sory that the answer came late. Thanks ANW.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now