Visual Basic - entre dos fechas

Life is soft - evento anual de software empresarial
 
Vista:

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
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:entre dos fechas

Publicado por Contestador automatico (2 intervenciones) el 02/03/2006 10:32:45
donde pones "&" a la hora de ejecutar la funcion "BUSCARfecha", tienes que sustituirla por una coma ( , ) ya que el segundo "format" es el segundo parametro de la funcion, osea, "f2"

BUSCARfecha Format(txtfecha.Text, "dd/mm/yyyy") & Format(txtfecha1.Text, "dd/mm/yyyy")

la funcion
Public Sub BUSCARfecha(f1 As Date, f2 As Date)
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar