Acotar entre fechas
Carlos:
el codigo que te envie lo que necesito es generar una busqueda entre fechas acotadas, no he tenido respuesta solo pistas de respuesta lo que necesito es terminar este codigo, mira el codigo acota las fechas, me genera la suma de datos de iva, neto y totalpero que necesito es generar un text que pueda ademas buscar entre estas fechas un datos o datos en particular, como se trata de ingrasos de compras los datos se repiten ej, cemento, madera etc..., el codigo completo:
Public cn As ADODB.Connection
Private Sub Form_Activate()
CentrarForma Me
End Sub
Private Sub cmdReporte_Click()
datare1.netototal Format(CDate(mkbFec1.Text), "mm/dd/yy"), Format(CDate(mkbFec2.Text), "mm/dd/yy")
DataReport1.Refresh
DataReport1.Show
datare1.rsnetototal.Close
cmdReporte.Enabled = False
End Sub
Private Sub Form_Load()
SSTab1.Caption = ""
With mfgReporte
.ColWidth(0) = 1000 '2500
.TextMatrix(0, 0) = "NºORDEN" ' "CLIENTE"
.ColWidth(1) = 1200
.TextMatrix(0, 1) = "FECHA" ' "TELEFONO"
.ColWidth(2) = 2000
.TextMatrix(0, 2) = "GUIA DESPACHO" ' "FECHA"
.ColWidth(3) = 1500
.TextMatrix(0, 3) = "FACTURA" '"PAGO"
.ColWidth(4) = 1000
.TextMatrix(0, 4) = "PROVEEDOR"
.ColWidth(5) = 1000
.TextMatrix(0, 5) = "MOVIL"
.ColWidth(6) = 1800
.TextMatrix(0, 6) = "CENTRO COSTO"
.ColWidth(7) = 1200
.TextMatrix(0, 7) = "DETALLE"
.ColWidth(8) = 1000
.TextMatrix(0, 8) = "NETO"
.ColWidth(9) = 1000
.TextMatrix(0, 9) = "IVA"
.ColWidth(10) = 1000
.TextMatrix(0, 10) = "TOTAL"
End With
On Error GoTo Mensaje
Set cn = New Connection
Path = App.Path & "\ccosto.mdb"
cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Path & ""
frmReporte.Show
Exit Sub
Mensaje:
MsgBox "No se establecio la conexión con la Base de Datos", vbCritical, "ATENCION"
End Sub
Private Sub mkbFec1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
mkbFec2.Enabled = True
mkbFec2.SetFocus
End If
End Sub
Private Sub mkbFec2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text1.Enabled = True
Text1.SetFocus
End If
End Sub
Private Sub CmdSalir_Click()
Unload Me
End Sub
Private Sub cmdVisualizar_Click()
Dim rs1 As ADODB.Recordset
Dim sum As Integer
Dim sum1 As Integer
Dim sum2 As Integer
Set rs1 = New Recordset
Fec1 = Format(CDate(mkbFec1.Text), "mm/dd/yy")
Fec2 = Format(CDate(mkbFec2.Text), "mm/dd/yy")
'rs1.Open "SELECT Norden, Fecha, Guiadespacho, Factura, Proveedor, movil, ccosto, detalle, neto, iva, total FROM ingcosto WHERE Fecha between #" & Fec1 & "# AND #" & Fec2 & "# ORDER BY Fecha", cn (Sin text y funciona)
rs1.Open "SELECT Norden, Fecha, Guiadespacho, Factura, Proveedor, movil, ccosto, detalle, neto, iva, total FROM ingcosto WHERE fecha between # " & Fec1 & "# and # " & Fec2 & "# AND ccosto = " & textbox1.Text & " order by fecha", cn
txtReg.Text = rs1.RecordCount
filas = 2
With mfgReporte
Do While Not rs1.EOF
.Rows = filas
.TextMatrix(filas - 1, 0) = rs1.Fields(0)
.TextMatrix(filas - 1, 1) = rs1.Fields(1)
.TextMatrix(filas - 1, 2) = rs1.Fields(2)
.TextMatrix(filas - 1, 3) = rs1.Fields(3)
.TextMatrix(filas - 1, 4) = rs1.Fields(4)
.TextMatrix(filas - 1, 5) = rs1.Fields(5)
.TextMatrix(filas - 1, 6) = rs1.Fields(6)
.TextMatrix(filas - 1, 7) = rs1.Fields(7)
.TextMatrix(filas - 1, 8) = Format(rs1.Fields(8), "###.00")
.TextMatrix(filas - 1, 9) = Format(rs1.Fields(9), "###.00") 'rs1.Fields(9)
.TextMatrix(filas - 1, 10) = Format(rs1.Fields(10), "###.00") 'rs1.Fields(10)
sum = sum + Val(.TextMatrix(filas - 1, 8))
sum1 = sum1 + Val(.TextMatrix(filas - 1, 9))
sum2 = sum2 + Val(.TextMatrix(filas - 1, 10))
txtPago.Text = Format(sum, "###.00")
txtiva.Text = Format(sum1, "###.00")
txttotal.Text = Format(sum2, "###.00")
rs1.MoveNext
filas = filas + 1
Loop
End With
cmdVisualizar.Enabled = False
cmdReporte.Enabled = True
cmdReporte.SetFocus
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdVisualizar.Enabled = True
cmdVisualizar.SetFocus
End If
End Sub
espero tu respueta gracias
el codigo que te envie lo que necesito es generar una busqueda entre fechas acotadas, no he tenido respuesta solo pistas de respuesta lo que necesito es terminar este codigo, mira el codigo acota las fechas, me genera la suma de datos de iva, neto y totalpero que necesito es generar un text que pueda ademas buscar entre estas fechas un datos o datos en particular, como se trata de ingrasos de compras los datos se repiten ej, cemento, madera etc..., el codigo completo:
Public cn As ADODB.Connection
Private Sub Form_Activate()
CentrarForma Me
End Sub
Private Sub cmdReporte_Click()
datare1.netototal Format(CDate(mkbFec1.Text), "mm/dd/yy"), Format(CDate(mkbFec2.Text), "mm/dd/yy")
DataReport1.Refresh
DataReport1.Show
datare1.rsnetototal.Close
cmdReporte.Enabled = False
End Sub
Private Sub Form_Load()
SSTab1.Caption = ""
With mfgReporte
.ColWidth(0) = 1000 '2500
.TextMatrix(0, 0) = "NºORDEN" ' "CLIENTE"
.ColWidth(1) = 1200
.TextMatrix(0, 1) = "FECHA" ' "TELEFONO"
.ColWidth(2) = 2000
.TextMatrix(0, 2) = "GUIA DESPACHO" ' "FECHA"
.ColWidth(3) = 1500
.TextMatrix(0, 3) = "FACTURA" '"PAGO"
.ColWidth(4) = 1000
.TextMatrix(0, 4) = "PROVEEDOR"
.ColWidth(5) = 1000
.TextMatrix(0, 5) = "MOVIL"
.ColWidth(6) = 1800
.TextMatrix(0, 6) = "CENTRO COSTO"
.ColWidth(7) = 1200
.TextMatrix(0, 7) = "DETALLE"
.ColWidth(8) = 1000
.TextMatrix(0, 8) = "NETO"
.ColWidth(9) = 1000
.TextMatrix(0, 9) = "IVA"
.ColWidth(10) = 1000
.TextMatrix(0, 10) = "TOTAL"
End With
On Error GoTo Mensaje
Set cn = New Connection
Path = App.Path & "\ccosto.mdb"
cn.CursorLocation = adUseClient
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Path & ""
frmReporte.Show
Exit Sub
Mensaje:
MsgBox "No se establecio la conexión con la Base de Datos", vbCritical, "ATENCION"
End Sub
Private Sub mkbFec1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
mkbFec2.Enabled = True
mkbFec2.SetFocus
End If
End Sub
Private Sub mkbFec2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text1.Enabled = True
Text1.SetFocus
End If
End Sub
Private Sub CmdSalir_Click()
Unload Me
End Sub
Private Sub cmdVisualizar_Click()
Dim rs1 As ADODB.Recordset
Dim sum As Integer
Dim sum1 As Integer
Dim sum2 As Integer
Set rs1 = New Recordset
Fec1 = Format(CDate(mkbFec1.Text), "mm/dd/yy")
Fec2 = Format(CDate(mkbFec2.Text), "mm/dd/yy")
'rs1.Open "SELECT Norden, Fecha, Guiadespacho, Factura, Proveedor, movil, ccosto, detalle, neto, iva, total FROM ingcosto WHERE Fecha between #" & Fec1 & "# AND #" & Fec2 & "# ORDER BY Fecha", cn (Sin text y funciona)
rs1.Open "SELECT Norden, Fecha, Guiadespacho, Factura, Proveedor, movil, ccosto, detalle, neto, iva, total FROM ingcosto WHERE fecha between # " & Fec1 & "# and # " & Fec2 & "# AND ccosto = " & textbox1.Text & " order by fecha", cn
txtReg.Text = rs1.RecordCount
filas = 2
With mfgReporte
Do While Not rs1.EOF
.Rows = filas
.TextMatrix(filas - 1, 0) = rs1.Fields(0)
.TextMatrix(filas - 1, 1) = rs1.Fields(1)
.TextMatrix(filas - 1, 2) = rs1.Fields(2)
.TextMatrix(filas - 1, 3) = rs1.Fields(3)
.TextMatrix(filas - 1, 4) = rs1.Fields(4)
.TextMatrix(filas - 1, 5) = rs1.Fields(5)
.TextMatrix(filas - 1, 6) = rs1.Fields(6)
.TextMatrix(filas - 1, 7) = rs1.Fields(7)
.TextMatrix(filas - 1, 8) = Format(rs1.Fields(8), "###.00")
.TextMatrix(filas - 1, 9) = Format(rs1.Fields(9), "###.00") 'rs1.Fields(9)
.TextMatrix(filas - 1, 10) = Format(rs1.Fields(10), "###.00") 'rs1.Fields(10)
sum = sum + Val(.TextMatrix(filas - 1, 8))
sum1 = sum1 + Val(.TextMatrix(filas - 1, 9))
sum2 = sum2 + Val(.TextMatrix(filas - 1, 10))
txtPago.Text = Format(sum, "###.00")
txtiva.Text = Format(sum1, "###.00")
txttotal.Text = Format(sum2, "###.00")
rs1.MoveNext
filas = filas + 1
Loop
End With
cmdVisualizar.Enabled = False
cmdReporte.Enabled = True
cmdReporte.SetFocus
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
cmdVisualizar.Enabled = True
cmdVisualizar.SetFocus
End If
End Sub
espero tu respueta gracias
1 respuesta
Respuesta de carloscharly
1