GODIGO
Publicado por mati (10 intervenciones) el 30/05/2005 17:56:46
Hola yo tengo el suiguiente codigo
Case "TUnidadesOrdenado por maquinas"
CryReport.WindowTitle = "Listado Tiempo\Maquina"
CryReport.ReportFileName = App.Path & "\listados\articulo_maquina2.rpt"
CryReport.Formulas(0) = "NombreEmpresa=" & "'" & MDIGestion.Caption & "'"
CryReport.Formulas(1) = "DesdeMaquina=" & "'" & TxtTexto(1).Text & "'"
CryReport.Formulas(2) = "HastaMaquina=" & "'" & TxtTexto(2).Text & "'"
CryReport.Formulas(3) = "DesdeArticulo=" & "'" & TxtTexto(3).Text & "'"
CryReport.Formulas(4) = "HastaArticulo=" & "'" & TxtTexto(4).Text & "'"
CryReport.Destination = Destino
'MsgBox (CryReport.SelectionFormula)
If Len(TxtTexto(2).Text) <> 0 Then
cod_maq_primero = ""
cod_maq_ultimo = ""
strSQL = "Select distinct(codart) as codigo_articulo From tunidad where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "'"
'order by Codmaq,codart"
'strSQL = "Select * From Tunidad where TUnidad.CodMaq>= " & "'" & txtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & txtTexto(2).Text & "'"
'where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "'"
'and " & "'" & "TUnidad.CodMaq=TxtTexto(2).Text " & "'" & " and " & "'" & TUnidad.CodArt=TxtTexto(3).Text " & "'" & " and " & "'" & TUnidad.CodArt=TxtTexto(4).Text"
MsgBox (strSQL)
strSQL1 = "Select count(distinct(codart)) as num_registro From tunidad where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "'"
'where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "' group by codmaq"
'where TUnidad.CodMaq= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt= " & "'" & TxtTexto(4).Text & "'"
MsgBox (strSQL1)
Set Registro = Nothing: Registro.Open strSQL, Connection, adOpenKeyset, adLockPessimistic
Set Registro1 = Nothing: Registro1.Open strSQL1, Connection, adOpenKeyset, adLockPessimistic
i = 1
cont_pag = 0
If Registro1!num_registro > 5 Then
'Do Until Registro1.EOF
Do Until Registro.EOF
i = i + 1
'MsgBox (Registro1!num_registro)
'MsgBox (Registro!num_registro)
MsgBox (Registro!codigo_maquina)
Registro.MoveNext
If i = 1 Then
cod_maq_primero = Registro!codigo_articulo
End If
'i = Registro1!num_registro
If i = 9 Then
If cod_maq_ultimo = "" Then
'cod_maq_primero = Registro!codigo_maquina
cod_maq_ultimo = Registro!codigo_articulo
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(2).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & TxtTexto(3).Text & "'" & " and {TUnidad.CodArt}<=" & "'" & cod_maq_ultimo & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
i = 0
Else
'cod_maq_primero = cod_maq_ultimo
cod_maq_ultimo = Registro!codigo_articulo
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(2).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & cod_maq_primero & "'" & " and {TUnidad.CodArt}<=" & "'" & cod_maq_ultimo & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
i = 0
End If
End If
Loop
End If
If i > 1 And i < 9 Then
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(2).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & cod_maq_primero & "'" & " and {TUnidad.CodArt}<=" & "'" & TxtTexto(4).Text & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
End If
If i = 1 Then
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(4).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & TxtTexto(3).Text & "'" & " and {TUnidad.CodArt}<=" & "'" & TxtTexto(4).Text & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
End If
Bien con este codigo lo que hago es qe si los registros de un informe no me entran en una misma pagina hago diferentes informes yo lo que quiero es hacer una nueva hoja al infome en lugar de un nuevo informe eso se puede hacer.
No lo puedo hacer desde crystal en nueva pagina porque tengo tablas cruzadas y en detalle no hay nada en ncabezado de informes eso no funcion
Muxas gracias
Case "TUnidadesOrdenado por maquinas"
CryReport.WindowTitle = "Listado Tiempo\Maquina"
CryReport.ReportFileName = App.Path & "\listados\articulo_maquina2.rpt"
CryReport.Formulas(0) = "NombreEmpresa=" & "'" & MDIGestion.Caption & "'"
CryReport.Formulas(1) = "DesdeMaquina=" & "'" & TxtTexto(1).Text & "'"
CryReport.Formulas(2) = "HastaMaquina=" & "'" & TxtTexto(2).Text & "'"
CryReport.Formulas(3) = "DesdeArticulo=" & "'" & TxtTexto(3).Text & "'"
CryReport.Formulas(4) = "HastaArticulo=" & "'" & TxtTexto(4).Text & "'"
CryReport.Destination = Destino
'MsgBox (CryReport.SelectionFormula)
If Len(TxtTexto(2).Text) <> 0 Then
cod_maq_primero = ""
cod_maq_ultimo = ""
strSQL = "Select distinct(codart) as codigo_articulo From tunidad where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "'"
'order by Codmaq,codart"
'strSQL = "Select * From Tunidad where TUnidad.CodMaq>= " & "'" & txtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & txtTexto(2).Text & "'"
'where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "'"
'and " & "'" & "TUnidad.CodMaq=TxtTexto(2).Text " & "'" & " and " & "'" & TUnidad.CodArt=TxtTexto(3).Text " & "'" & " and " & "'" & TUnidad.CodArt=TxtTexto(4).Text"
MsgBox (strSQL)
strSQL1 = "Select count(distinct(codart)) as num_registro From tunidad where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "'"
'where TUnidad.CodMaq>= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq<= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt>=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt<= " & "'" & TxtTexto(4).Text & "' group by codmaq"
'where TUnidad.CodMaq= " & "'" & TxtTexto(1).Text & "'" & " and TUnidad.CodMaq= " & "'" & TxtTexto(2).Text & "'" & " and TUnidad.CodArt=" & "'" & TxtTexto(3).Text & "'" & " and TUnidad.CodArt= " & "'" & TxtTexto(4).Text & "'"
MsgBox (strSQL1)
Set Registro = Nothing: Registro.Open strSQL, Connection, adOpenKeyset, adLockPessimistic
Set Registro1 = Nothing: Registro1.Open strSQL1, Connection, adOpenKeyset, adLockPessimistic
i = 1
cont_pag = 0
If Registro1!num_registro > 5 Then
'Do Until Registro1.EOF
Do Until Registro.EOF
i = i + 1
'MsgBox (Registro1!num_registro)
'MsgBox (Registro!num_registro)
MsgBox (Registro!codigo_maquina)
Registro.MoveNext
If i = 1 Then
cod_maq_primero = Registro!codigo_articulo
End If
'i = Registro1!num_registro
If i = 9 Then
If cod_maq_ultimo = "" Then
'cod_maq_primero = Registro!codigo_maquina
cod_maq_ultimo = Registro!codigo_articulo
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(2).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & TxtTexto(3).Text & "'" & " and {TUnidad.CodArt}<=" & "'" & cod_maq_ultimo & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
i = 0
Else
'cod_maq_primero = cod_maq_ultimo
cod_maq_ultimo = Registro!codigo_articulo
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(2).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & cod_maq_primero & "'" & " and {TUnidad.CodArt}<=" & "'" & cod_maq_ultimo & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
i = 0
End If
End If
Loop
End If
If i > 1 And i < 9 Then
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(2).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & cod_maq_primero & "'" & " and {TUnidad.CodArt}<=" & "'" & TxtTexto(4).Text & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
End If
If i = 1 Then
CryReport.SelectionFormula = "{TUnidad.CodMaq}>=" & "'" & TxtTexto(1).Text & "'" & " and {TUnidad.CodMaq}<=" & "'" & TxtTexto(4).Text & "'" & " and {TUnidad.CodArt}>=" & "'" & TxtTexto(3).Text & "'" & " and {TUnidad.CodArt}<=" & "'" & TxtTexto(4).Text & "'"
MsgBox (CryReport.SelectionFormula)
CryReport.PrintReport
End If
Bien con este codigo lo que hago es qe si los registros de un informe no me entran en una misma pagina hago diferentes informes yo lo que quiero es hacer una nueva hoja al infome en lugar de un nuevo informe eso se puede hacer.
No lo puedo hacer desde crystal en nueva pagina porque tengo tablas cruzadas y en detalle no hay nada en ncabezado de informes eso no funcion
Muxas gracias
Valora esta pregunta


0