Auto completar un textbox desde una BD


/ Published in: Visual Basic
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Public KeyRetroceso As Boolean
  2.  
  3.  
  4. Private Sub TDESCRIPCION_BREVE_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
  5. If KeyCode = vbKeyBack Or KeyCode = vbKeyDelete Then
  6. ' ..si hay texto en el Textbox
  7. If Len(TDESCRIPCION_BREVE.Text) <> 0 Then
  8. KeyRetroceso = True
  9. End If
  10. End If
  11. End Sub
  12.  
  13. Function Autocompletar_FlexGrid(TBox As Object, texto As String)
  14. 'buscar las coincidencias de las descripcion breves ya ingresadas al sistema _
  15. si las carga en el textbox de pantalla
  16. Dim i As Integer
  17. Dim pos_SelStart As Integer
  18. Dim rst As ADODB.Recordset
  19. Set rst = New ADODB.Recordset
  20. rst.Open "select descripcion_breve from ot where descripcion_breve like '" & texto & "%'", cnt, adOpenStatic
  21. If rst.EOF <> True Then
  22. If (KeyRetroceso Or Len(TBox.Text) = 0) Then
  23. KeyRetroceso = False
  24. Exit Function
  25. End If
  26. pos_SelStart = TBox.SelStart
  27. TBox.Text = rst!DESCRIPCION_BREVE
  28. TBox.SelStart = pos_SelStart
  29. TBox.SelLength = Len(rst!DESCRIPCION_BREVE) - pos_SelStart
  30. End If
  31. rst.Close
  32. End Function

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.