Solved

AUTOCOMPLETING A DATACOMBOBOX/ SORT ALPHABETICALLY

Posted on 2001-06-29
13
356 Views
Last Modified: 2007-11-27
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
0
Comment
Question by:ELSJE
  • 5
  • 5
  • 2
  • +1
13 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6237415
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
 

Author Comment

by:ELSJE
ID: 6237539
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
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 6237549
Hi ELSJE, thanks to inform me that. Maybe i shall try myself later.
0
 

Author Comment

by:ELSJE
ID: 6237749
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6239273
did you try with mtchentry property?
0
 

Author Comment

by:ELSJE
ID: 6240282
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6241414
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
 

Author Comment

by:ELSJE
ID: 6241979
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
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6242332
Could you please turn caps off.
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 100 total points
ID: 6243096
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6243098
By the way, MSDN is on net, in Microsoft site.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6243102
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
 

Author Comment

by:ELSJE
ID: 6249150
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

747 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

10 Experts available now in Live!

Get 1:1 Help Now