'En la parte de declaracione generales
Dim cnnMiCon As ADODB.Connection
Dim cmdCriterio As ADODB.Command
Dim rstTabla As ADODB.Recordset
'
'
'
'En el botón de búsqueda
Private Sub Buscar()
Dim inicial As Date
Dim final As Date
'
If txtFechaInicial.Text <> "" And txtFechaFinal.Text <> "" Then
'
Set rstTabla = Nothing
Set cmdCriterio = Nothing
Set cnnMiCon = Nothing
'
inicial = txtFechaInicial.Text
final = txtFechaFinal.Text
'
Set cnnMiCon = New ADODB.Connection
Set cmdCriterio = New ADODB.Command
Set rstTabla = New ADODB.Recordset
'
cnnMiCon.ConnectionString = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=C:\WINDOWS\Escritorio\ProyectoFechas\fechas97_1.mdb"
cnnMiCon.Open
'
cmdCriterio.CommandText = "SELECT cedula,nombre,fechaNac FROM tabla1 WHERE fechaNac>'" & inicial & "'" And fechaNac < "'" & final & "'"
'
rstTabla.Open cmdCriterio.CommandText, cnnMiCon, adOpenDynamic
'
rstTabla.MoveFirst
txtCedula = rstTabla.Fields("cedula").Value
txtNombre = rstTabla.Fields("nombre").Value
txtFecha = rstTabla.Fields("fechaNac").Value
End If
End Sub