Aii Victorsam fiz meio rapidinho, tá funcionando tudo certinho, só adaptar a sua necessidades ...
Private Sub CommandButton1_Click()
On Error Resume Next
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim CaminhoArquivo, Provedor As String
Dim sql, Tabela As String
Provedor = "Microsoft.ACE.OLEDB.12.0;DATA SOURCE="
CaminhoArquivo = ThisWorkbook.Path & "BancoVencimento.accdb"
cn.Provider = Provedor & CaminhoArquivo
Me.ListView1.ListItems.Clear
Me.ListView1.ColumnHeaders.Clear
Me.ListView1.View = lvwReport
Me.ListView1.Gridlines = True
Me.ListView1.FullRowSelect = True
Me.ListView1.ColumnHeaders.Add , , "ID"
Me.ListView1.ColumnHeaders.Add , , "Nome"
Me.ListView1.ColumnHeaders.Add , , "Data"
Me.ListView1.ColumnHeaders(1).Width = 50
Me.ListView1.ColumnHeaders(2).Width = 171
Me.ListView1.ColumnHeaders(3).Width = 100
sql = "SELECT * FROM tbLançamentos ORDER BY Data, Data"
cn.Open
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
rs.PageSize = 42
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
rs.Filter = "Data >=#" & Format(Me.DataInicial, "dd/mm/yyyy") & "# and Data<=#" & Format(Me.DataFinal, "dd/mm/yyyy") & "#"
If Not rs.RecordCount > 0 Then Exit Sub
rs.MoveFirst
I = 0
Dim li As ListItem
Do
Set li = ListView1.ListItems.Add(Text:=rs![Id])
li.ListSubItems.Add Text:=rs![NOME]
li.ListSubItems.Add Text:=rs![Data]
rs.MoveNext
DoEvents
Loop Until rs.EOF
Desconectar
End Sub
Postado : 12/10/2014 5:38 pm