Advertisement
4_2005-2006 Databases/ Data Access/ DAO/ ADO #150416

Text Box Auto Fill

This simple code allows to make an auto-filled textbox (like an adress box in IE). This example uses an DataEnvironment connection, but it can be easy used in any other cases.

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
Private Sub txtSTREET_KeyUp(KeyCode As Integer, Shift As Integer)
Dim PrevLength  As Integer, PrevStart As Integer
If Not KeyCode >= 65 Then Exit Sub
If firstcome Then firstcome = False: Exit Sub
  With DataEnvironment.Connection1.Execute("SELECT ADDRESS from tblFlats WHERE UCASE(ADDRESS) like '" & UCase(Me.txtSTREET) & "%'")
    If Not .EOF Then
      If Not Me.txtSTREET = "" Then
        PrevStart = Len(Me.txtSTREET) + 1
        PrevLength = -Len(Me.txtSTREET) + Len(!ADDRESS)
        Me.txtSTREET.SelStart = PrevStart
        Me.txtSTREET.SelLength = PrevLength
        Me.txtSTREET.SelText = Mid$(!ADDRESS, Len(Me.txtSTREET) + 1)
        Me.txtSTREET.SelStart = PrevStart - 1
        Me.txtSTREET.SelLength = PrevLength
      End If
    'Else
      'MsgBox "The entered fragment is not found in the list!"
      'Me.STREET = ""
    End If
  End With
End Sub

Upload
Upload
원본 댓글 (3)
Wayback Machine에서 복구됨