CONSULTA INTERVALO DE DATAS

USUARIO.EXCLUIDOS 10/11/2004 12:38:52
#49732
Bom dia, amigos!
Já pesquisei e não consigo solucionar o meu problema.Estou tentando trazer os dados em um datagrid e como parametros dois datapickers para especificar as datas, mas o grid não traz nada. abaixo o código

Public conexao As New Connection
Public rs As New Recordset
Public sql As String

Private Sub Command1_Click()

conexao.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\ACP\ACP.mdb;Persist Security Info=False"
conexao.Open
conexao.CursorLocation = adUseClient
sql = "Select * from tab_Caixa where data between DateValue('" & dtini & "')and DateValue('" & dtfin & "')"
rs.Source = sql
Set rs.ActiveConnection = conexao
rs.Open
Set DataGrid1.DataSource = rs

conexao.Close
End Sub

Desculpa se há algo errado, sou novato no fórum e aliás o meu primeiro post.
Obrigado
LIONDAS 10/11/2004 14:11:46
#49749
Resposta escolhida
Eu sempre tive problemas com data mas procuro utilizar no sql esta sintaxe:

sql = "Select * from tab_Caixa where data between #" & format(dtini,"mm/dd/yyyy") & "# and #" & format(dtfin,"mm/dd/yyyy") & "#"

Deste jeito sempre consigo selecionar datas.
Tópico encerrado , respostas não são mais permitidas