USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Fórum

  Visual Basic
Voltar
Autor Assunto:  Atualização de combo e função auto-completar
Ribeiro
não registrado
ENUNCIADA !
Postada em 24/09/2004 11:54 hs   
Caros amigos, estou precisando de uma função que atualize o combobox com os dados contidos no BD e que, no momento em que é digitado um nome (por exemplo) que já esteja contido no BD, este mesmo nome ja apareça no combo.
 
Um Abraço e Obrigado
   
Eledio Junior
Pontos: 2843
CAÇADOR
SC - BRASIL
ENUNCIADA !
Postada em 24/09/2004 12:25 hs         
Vamos Lá
 
Insira:
TextBox = txtNome
ListBox = lstNome
 
 
 
Dim DelBack As Boolean
Dim ListClick As Boolean
 
 
Private Sub txtNome_Change()
    Dim I As Integer
    If ListClick Then
        ListClick = False
        Exit Sub
    End If
    Set TB = BD.OpenRecordset("SELECT Nome FROM Funcionários WHERE Nome LIKE '" & txtNome.Text & "*' ORDER BY Nome asc")
    If (TB.RecordCount <> 0) Then
        TB.MoveMax
        TB.MoveMin
        I = txtNome.SelStart
        If (txtNome.Text <> "") And (Not DelBack) And (TB.RecordCount <> 0) Then txtNome.Text = TB!Nome
       
        If (TB.RecordCount > 1) Then
            lstNome.Visible = True
            lstNome.Clear
            While Not TB.EOF
                lstNome.AddItem TB!Nome
                TB.MoveNext
            Wend
        End If
        txtNome.SelStart = I
        txtNome.SelLength = Len(txtNome.Text)
    End If
End Sub
 
Private Sub txtNome_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyDelete Or KeyCode = vbKeyBack Then
        DelBack = True
    Else
        DelBack = False
    End If
    'DESCER
    If (KeyCode = vbKeyDown) And (lstNome.Visible = True) Then
        lstNome.SetFocus
    End If
    'DESCER
    If (KeyCode = vbKeyReturn) Then
        lstNome.Visible = False
        cmdIncluir.SetFocus
    End If
End Sub
 
Private Sub lstNome_Click()
    ListClick = True
    txtNome.Text = lstNome.List(lstNome.ListIndex)
    Sel txtNome
End Sub
 
Private Sub lstNome_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyReturn) Then
        lstNome.Visible = False
        txtNome.SetFocus
    End If
End Sub
 
Public Sub Sel(objeto As TextBox)
    objeto.SelStart = 0
    objeto.SelLength = Len(objeto)
    objeto.SetFocus
End Sub
 
Pra Colocar em Combo è Só Fazer Alguns Ajustes... Qualquer Coisa.. é So Contatar-me
   
Página(s): 1/1    


Seu Nome:

Seu eMail:

ALTERAR PARA MODO HTML
Mensagem:

[:)] = 
[:P] = 
[:(] = 
[;)] = 

HTML DESLIGADO

     
 VOLTAR

  



CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página