entre dos fechas
Publicado por vibet (25 intervenciones) el 02/03/2006 02:07:46
Tengo el típico problema con las fechas, he buscado informacion en el foro y en codigo fuente y no doy con ello.Tengo una búsqueda por fechas y pretendo recoger de una base de datos acces unos registros comprendidos entre dos fechas, uso el siguiente codigo y me da error ""el argumento no es opcional""
en el boton tras escribir dos fechas
Private Sub imgBuscarfecha_Click()
f1 = "txtfecha.Text"
f2 = "txtfecha1.text"
BUSCARfecha Format(txtfecha.Text, "dd/mm/yyyy") & Format(txtfecha1.Text, "dd/mm/yyyy")
la funcion
Public Sub BUSCARfecha(f1 As Date, f2 As Date)
Dim titulo As String
titulo = "alerta"
If f1 > Date Then
MsgBox "Introduzca Una fecha correcta", vbInformation, titulo
Else
sbase = "c:\pruebas\base\base.mdb"
Set db = OpenDatabase(sbase)
sql = ("SELECT CAB_COMPRA.NUMCOMPRA, CAB_COMPRA.FECHAEMISION, COMPRAS.BASE_IMPONIBLE FROM (CAB_COMPRA RIGHT JOIN COMPRAS ON CAB_COMPRA.NUMCOMPRA = COMPRAS.NUMCOMPRA) where CAB_COMPRA.FECHAEMISION >=#" & Format(f1, "YYYY/MM/DD") & "# and fecha <= #" & Format(f2, "YYYY/MM/DD") & "#" & "GROUP BY CAB_COMPRA.NUMCOMPRA, CAB_COMPRA.FECHAEMISION, COMPRAS.BASE_IMPONIBLE")
Set Rst = db.OpenRecordset(sql)
nInd = 1
GrdInfoFacturas.Rows = 1
Do While Not Rst.EOF
GrdInfoFacturas.Rows = nInd + 1
GrdInfoFacturas.TextMatrix(nInd, 0) = Rst("num")
GrdInfoFacturas.TextMatrix(nInd, 1) = Rst("fechaemision")
GrdInfoFacturas.TextMatrix(nInd, 2) = Rst("tipo") & "€"
Rst.MoveNext
nInd = nInd + 1
Loop
End If
End Sub
muchas gracias
en el boton tras escribir dos fechas
Private Sub imgBuscarfecha_Click()
f1 = "txtfecha.Text"
f2 = "txtfecha1.text"
BUSCARfecha Format(txtfecha.Text, "dd/mm/yyyy") & Format(txtfecha1.Text, "dd/mm/yyyy")
la funcion
Public Sub BUSCARfecha(f1 As Date, f2 As Date)
Dim titulo As String
titulo = "alerta"
If f1 > Date Then
MsgBox "Introduzca Una fecha correcta", vbInformation, titulo
Else
sbase = "c:\pruebas\base\base.mdb"
Set db = OpenDatabase(sbase)
sql = ("SELECT CAB_COMPRA.NUMCOMPRA, CAB_COMPRA.FECHAEMISION, COMPRAS.BASE_IMPONIBLE FROM (CAB_COMPRA RIGHT JOIN COMPRAS ON CAB_COMPRA.NUMCOMPRA = COMPRAS.NUMCOMPRA) where CAB_COMPRA.FECHAEMISION >=#" & Format(f1, "YYYY/MM/DD") & "# and fecha <= #" & Format(f2, "YYYY/MM/DD") & "#" & "GROUP BY CAB_COMPRA.NUMCOMPRA, CAB_COMPRA.FECHAEMISION, COMPRAS.BASE_IMPONIBLE")
Set Rst = db.OpenRecordset(sql)
nInd = 1
GrdInfoFacturas.Rows = 1
Do While Not Rst.EOF
GrdInfoFacturas.Rows = nInd + 1
GrdInfoFacturas.TextMatrix(nInd, 0) = Rst("num")
GrdInfoFacturas.TextMatrix(nInd, 1) = Rst("fechaemision")
GrdInfoFacturas.TextMatrix(nInd, 2) = Rst("tipo") & "€"
Rst.MoveNext
nInd = nInd + 1
Loop
End If
End Sub
muchas gracias
Valora esta pregunta


0