AUTOCOMPLETING A DATACOMBOBOX/ SORT ALPHABETICALLY

DOES SOMEBODY KNOW HOW TO MAKE ,WHEN THE USER STARTS TO TYPE IN A DATACOMBOBOX, THAT THE FIRTST MATCHING ITEM IN THE LIST APPEARS AUTOMATICALLY? I KNOW THAT IT CAN WORK WITH A NORMAL COMBOBOX, BUT CAN THIS ALSO BE DONE WITH A DATACOMBO???

FURTHERMORE, HOW CAN I MAKE THE ITEMS OF THE LIST IN A COMBOBOX APPEAR IN ALPHABETICAL ORDER. RIGHT NOW I AM DOING THIS WHEN I AM CREATING THE CONNECTIONS OF MY DATAENVIRONMENT (USING SQL). BUT THIS MAKES THAT WHENEVER I AM DOING AN UPDATE IN A FORM, BASED ON A SORTED DATAMEMBER, THE NEW REGISTER IMMEDIATELY ENTERS IN THE ALPHABETICAL ORDER. SO THE USER CAN'T SEE ANYMORE WHAT HE JUST UPDATED.


THANKS FOR YOUR HELP
ELSJEAsked:
Who is Participating?
 
Richie_SimonettiConnect With a Mentor IT OperationsCommented:
Bueno, si lees espa?ol fluidamete aqui va
(Well, if you could read spanish, here is)

MatchEntry (Propiedad)
     

Devuelve o establece un valor que indica como realiza el control DataCombo o DataList las busquedas basandose en los datos introducidos por el usuario.

Sintaxis

objeto.MatchEntry [= valor ]

La sintaxis de la propiedad MatchEntry consta de las siguientes partes:

Parte Descripcion
objeto Unaexpresion de objeto que se evalua como un objeto de la lista Se aplica a.
valor Una constante o un valor que define el comportamiento de un control cuando tiene el enfoque y el usuario introduce uno o mas caracteres, como se describe en Valores.


Valores

Los valores admitidos para valor son:

Valor Valor Descripcion
dblBasicMatching 0 Coincidencia basica. (Predeterminado) El control busca la siguiente aparicion del caracter introducido usando la primera letra de las entradas de la lista. Si escribe varias veces la misma letra se recorren todas las entradas de la lista que comiencen por dicha letra.
dblExtendedMatching 1 Coincidencia ampliada. El control busca una entrada que coincida con todos los caracteres introducidos. La busqueda se realiza a medida que se escriben los caracteres, perfeccionando posteriormente la busqueda.  


Comentarios

Cuando la propiedad MatchEntry se establece con dblExtendedMatching y el usuario introduce un caracter de retroceso o espera unos segundos, la cadena de busqueda se restablece.

Tipo de dato

Integer
0
 
Ryan ChongCommented:
Hi ELSJE,

Try this auto-complete sample, i don't know if it works too in datacombo, if not working please inform me, thanks.

Here is the code:

'Combo - Using the auto-complete function
Option Explicit
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Private Const CB_FINDSTRING = &H14C
Private Const CB_ERR = (-1)
Private Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const CB_SETCURSEL = &H14E
Private m_bEditFromCode As Boolean
Private Sub Form_Load()
    With Combo1
      .AddItem "VB Square"
      .AddItem "http://www.vbsquare.com"
      .AddItem "VB World"
      .AddItem "http://www.vb-world.net"
    End With
End Sub
Private Sub Combo1_Change()
    Dim i As Long, j As Long
    Dim strPartial As String, strTotal As String
    If m_bEditFromCode Then
        m_bEditFromCode = False
        Exit Sub
    End If
    With Combo1
        strPartial = .Text
        i = SendMessage(.hwnd, CB_FINDSTRING, -1, ByVal strPartial)
        If i <> CB_ERR Then
            strTotal = .List(i)
            j = Len(strTotal) - Len(strPartial)
            If j <> 0 Then
                m_bEditFromCode = True
                .SelText = Right$(strTotal, j)
                'Select unmatched characters
                .SelStart = Len(strPartial)
                .SelLength = j
            End If
        End If
    End With
End Sub
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
    Case vbKeyDelete
      m_bEditFromCode = True
    Case vbKeyBack
      m_bEditFromCode = True
    End Select
End Sub

'Hope will help.
0
 
ELSJEAuthor Commented:
Sorry ryancys, this doesn't work at all.
it starts to give the error on .list
I guess this would be working perfectly with a normal combobox, but with datacombo it doesn't function.

els
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
Ryan ChongCommented:
Hi ELSJE, thanks to inform me that. Maybe i shall try myself later.
0
 
ELSJEAuthor Commented:
Hi ryancys, I would be very thankful if you could keep me informed. Unfortunately this is a question that has been asked before by other persons, but nobody seems to know a solution to this problem.

els
0
 
Richie_SimonettiIT OperationsCommented:
did you try with mtchentry property?
0
 
ELSJEAuthor Commented:
Hi Richie,

I tried this,I changed the property from 1 to 0 and back. I tried also various styles of comboboxes, but without the desired result.

els
0
 
Richie_SimonettiIT OperationsCommented:
I can't post MSDN article cause it is in spanish, but do a search in MSDN that comming with Visual studio for:
MatchEntry (property).
It appears to be what you are looking for.
0
 
ELSJEAuthor Commented:
THANKS RICHIE I WILL LOOK, BUT DON'T WORRY I DO SPEAK SPANISH FLUENTLY.
I WILL LOOK ON THE INTERNET IF I CAN FIND IT BECAUSE I DON'T HAVE MSDN INSTALLED. ESPERO QUE LO PUEDO ENCONTRAR!!

ELS
0
 
Éric MoreauSenior .Net ConsultantCommented:
Could you please turn caps off.
0
 
Richie_SimonettiIT OperationsCommented:
By the way, MSDN is on net, in Microsoft site.
0
 
Richie_SimonettiIT OperationsCommented:
One more thing.
Try not to use binded controls, populate it manually.
You could use a standard combo and use the code posted by ryancys.
0
 
ELSJEAuthor Commented:
Hi Richie,
dblextendedmatching in matchentry and dbcdropdownlist in style gives me more or less what I want. Could be better though

I know how to populate the combo when working with dao. For a lot of reasons I used this time a dataenvironment and unfortunately I don't see how to access the indexes .... when using this.

Thanks

els
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.