
27/09/2007, 07:06
|
| | Fecha de Ingreso: enero-2007
Mensajes: 55
Antigüedad: 18 años, 3 meses Puntos: 0 | |
autocompletar dbcombo He encontrado este codigo para autocompleat un combo pero cuando lo ejecuto me busca bien el primer caracter, pero cuando escribo el segundo me lo escribe al final del nombre, alguien sabe que pasa? ¿Hay alguna otra manera de autocompletar un dbcombo. Este dbcombo lo tengo asociado a una base de datos.
Public Function AutoComplete(ctlComboBox As Control)
Dim i%, intSel% ' % is a "shorthand" for Integers
'If this fires in response to a Backspace or Delete, then
'Exit the function because then you wouldn't be able to backup:
Select Case (Backspaced Or Len(DBCombo2.Text) = 0)
Case True: Backspaced = False: Exit Function
End Select
With ctlComboBox
'Run through the available items in a For...Loop and grab
'the first one that matches the selection:
Data1.Refresh
Do Until Data1.Recordset.EOF
If InStr(1, Data1.Recordset("nombre"), .Text, vbTextCompare) = 1 Then
intSel = .SelStart
.Text = Data1.Recordset("nombre")
.SelStart = intSel
.SelLength = Len(.Text) - intSel
Exit Do
End If
Data1.Recordset.MoveNext
Loop
End With
End Function |