lusky Posted April 30, 2015 at 11:23 PM Report Share #582246 Posted April 30, 2015 at 11:23 PM (edited) Boas Noites, Tenho o seguinte código feito para uma filtragem numérica de uma listview e funciona bem, o meu problema agora é acrescentar a este código mais um filtro mas que filtre texto, neste caso a palavra "Ruptura" e não estou a conseguir.... Mostro-vos o código para que entendam melhor: Private Sub MontaLista() txt1.Text = Date.Today() Try Dim SQL As String = "select * from Agenda" Dim where As String = "" If Not txtBuscar.Text = "" Then If cmbFiltro.Text = "Fornecedor" Then where = " where Fornecedor = " & txtBuscar.Text Else where = " where Itm8 like '%" & txtBuscar.Text & "%'" End If End If SQL += where ds.Reset() Dim adptr As New OleDbDataAdapter(SQL, conect_banco) adptr.Fill(ds) dt = ds.Tables(0) LV1.Items.Clear() Dim Item As ListViewItem For Each Me.dr In dt.Rows Item = LV1.Items.Add(dr.Item("ID")) Item.SubItems.Add(dr.Item("Itm8")) Item.SubItems.Add(dr.Item("Designacao")) Item.SubItems.Add(dr.Item("Fornecedor")) Item.SubItems.Add(dr.Item("Motivo")) Item.SubItems.Add(dr.Item("Registo")) Next Catch ex As Exception MsgBox("Erro: " & ex.Message) End Try End Sub Esse código acima está funcional mas tento colocar este filtro e retorna sempre erro: If cmbFiltro.Text = "Motivo" Then where = " where Motivo = " & txtBuscar.Text End If Agradecendo a Vossa ajuda. Cumps, Edited April 30, 2015 at 11:37 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
Solution Retsu9 Posted May 1, 2015 at 01:09 AM Solution Report Share #582251 Posted May 1, 2015 at 01:09 AM tenta : If cmbFiltro.Text = "Motivo" Then where = " where Motivo = '" & txtBuscar.Text & "'" End If 1 Report Link to comment Share on other sites More sharing options...
heytorthrasher Posted May 1, 2015 at 04:08 AM Report Share #582255 Posted May 1, 2015 at 04:08 AM Bem amigo eu não sei te responder, mas se souber a resposta para a minha pergunta poderia me ajudar? https://www.portugal-a-programar.pt/topic/70716-o-drop-down-do-meu-blog-nao-esta-funcionandoajuda-me/ Link to comment Share on other sites More sharing options...
lusky Posted May 1, 2015 at 10:56 AM Author Report Share #582264 Posted May 1, 2015 at 10:56 AM Bom dia, Muito Obrigado Retsu9, funcionou perfeitamente! O erro estava mesmo debaixo dos meus olhos....... 😉 Cumps, Link to comment Share on other sites More sharing options...
lusky Posted May 6, 2015 at 03:48 PM Author Report Share #582608 Posted May 6, 2015 at 03:48 PM (edited) Boas, É possível selecionar um segundo filtro na ListView após o primeiro já estar carregado? Isto é: Tenho 1 Combobox + TextBox com o seguinte código: If cmbFiltro.Text = "Fornecedor" Then where = " where Fornecedor = " & txtBuscar.Text Else where = " where Itm8 like '%" & txtBuscar.Text & "%'" End If Agora queria acrescentar mais uma combobox e mais uma textbox para fazer uma filtragem sobre a primeira, não sei como me explicar melhor... Agradecendo antecipadamente, Cumprimentos, Edited May 6, 2015 at 04:43 PM by apocsantos geshi Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now