Results 1 to 3 of 3

Thread: Auto filling textbox with data

  1. #1

    Thread Starter
    Fanatic Member spud's Avatar
    Join Date
    Aug 2000
    Location
    Munster (Germany)
    Posts
    542
    Is it possible to type into a text box that is connected to a datacontrol and if the text is matching any words already within the database field it auto fills?

    I have seen it done with a list box, is it possible and if it is then how can it be achived?

    Thanks Spud

  2. #2
    Member Red Thread's Avatar
    Join Date
    Aug 2000
    Location
    Europe-Belgium
    Posts
    44

    Talking Try This...

    I'm sending you an working example towards your email... hang on!

  3. #3

    Thread Starter
    Fanatic Member spud's Avatar
    Join Date
    Aug 2000
    Location
    Munster (Germany)
    Posts
    542

    Smile

    Red, got that thanks, I tried a code similer but a lot longer than the one you sent and I tryed to do it with a DBCombo but to no avail is there any way to asign the database field to the combo box?


    Thanks Again

    Spud

    (Regards from Sunny (Ha Ha) Scotland


    UpDate:

    Red Made these changes to a DBCombo with your code:Option Explicit

    '===============================================================================
    '
    '===============================================================================
    Private Sub CB_KeyUp(KeyCode As Integer, Shift As Integer)

    Static NoSelectText As String ' texte tapé par l'utilisateur
    Dim i As Long ' compteur de boucle
    Const RGBerror = 255 ' couleur du fond en cas d'erreur


    With DBCombo1 '<== SEULE LIGNE A MODIFIER

    ' touche que l'on ne doit pas gérer dans cette procedure
    If KeyCode = vbKeyUp Then Exit Sub ' utilisé par VB
    If KeyCode = vbKeyDown Then Exit Sub ' utilisé par vb
    If KeyCode = vbKeyLeft Then Exit Sub ' pour se déplacer
    If KeyCode = vbKeyRight Then Exit Sub ' pour se déplacer

    ' action spécial pour la touche BACK
    If KeyCode <> vbKeyBack Then
    NoSelectText = Mid(.Text, 1, Len(.Text) - .SelLength)
    Else
    If NoSelectText <> "" Then
    NoSelectText = Mid(NoSelectText, 1, Len(NoSelectText) - 1)
    End If
    End If

    ' recherche de la correspondance
    For i = 0 To .ListField - 1
    If UCase(NoSelectText) = UCase(Mid(.RowSource(i), 1, Len(NoSelectText))) Then
    .ListField = i
    Exit For
    End If
    Next

    ' selection de la partie que l'on a rajouté automatiquement
    .SelStart = Len(NoSelectText)
    .SelLength = Len(.Text)

    ' partie optionnelle qui change la couleur de fond en cas d'erreur
    If .ListField = -1 Then
    .BackColor = RGBerror
    Else
    .BackColor = vbWindowBackground
    End If

    End With

    End Sub




    What happens is as you type text the dropdown part of the DBCombo sorts through until it findes a match (Which is good) all i need to do is get the text to change within the DBCombo as you type,


    Any help would be nice

    Thanks

    Spud



    [Edited by spud on 08-23-2000 at 07:14 PM]

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