CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2013

    Unhappy Textbox auto-complete problem with ADODC1.

    Hi friends,
    continuously reviewed and tried a lot of examples, but I get an error.

    There on the table of sql server, and in the name of customer names, addresses, etc. fields.

    From the name of the textbox to enter the name of the auto-complete when I want to I want to enter in alphabetical order.

    I'm starting with t ADODC connection. Use the form to add the Connection string properties than in my painting I choose to build. Recordsource leave it blank. ADODC1 choose to add textbox datasource. text1 is change

    Table name: Customer
    Field: Name

    Private Sub Text1_Change()
    Form1.Adodc1.RecordSource = "select Name from Customer"
    Do Until Form1.Adodc1.Recordset.EOF
    j = Len(Text1.Text)
    If InStr(1, Mid(Form1.Adodc1.Recordset(0), 1, j), UCase(Text1.Text)) > 0 Then
    Text1.Text = Form1.Adodc1.Recordset(0)
    Text1.SelStart = j
    Text1.SelLength = Len(Text1.Text) - j
    End If
    End Sub

  2. #2
    DataMiser is offline Super Moderator Power Poster
    Join Date
    Jul 2008

    Re: Textbox auto-complete problem with ADODC1.

    Well first of all you should not be doing this in the change event. This will cause issues and slow your program down. As a rule never change the text of a textbox in the change event.

    Secondly do not use the data control

    And third do not pull all the records from the database and loop through them

    You should trigger the code using the keypress event so that it only runs when the user types
    You should use ADO code and an ADODB.Recordset object
    You should use the Like keyword in your select statement so that only the results which start with what the user has typed are returned, also you may want to use the Top keyword to make it return only the first match and place that in the text box. The result will be smaller, faster code.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Sep 2013

    Re: Textbox auto-complete problem with ADODC1.

    Do you have sample code that you can give me?

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.