
Relacion de 2 Tablas y pasarlo a texto
Publicado por Manuel Bañuelos (6 intervenciones) el 26/08/2006 14:30:25
Hola, a todos a ver si alguien tiene un ejemplo o que me diga como hacerlo en que estoy mal >>
Lo que kiero que salga es asi el Reporte :
Codigo : 38
Nombre : Saul
--------------------------------------------------------
Fecha | Entrada | Salida
------------------------------------------------------
02/02/2006 1:30 pm 2:45 pm
02/02/2006 7:00 am 1:00 pm
Codigo :100
Nombre : Rosal
--------------------------------------------------------
Fecha | Entrada | Salida
------------------------------------------------------
02/02/2006 1:30 pm 2:45 pm
Function Imprimir()
Dim X As Byte
Dim sql, como As String
Dim rs, rs2 As Recordset
Dim CONTA As Double
Dim PAG As Variant
Dim rs1 As Recordset
'
'Dim estados As String
'estados = "A"
MsgBox "!! Prepare la Impresora para Imprimir el Reporte !!", vbInformation + vbOKOnly, "Mensaje del sistema"
Kill App.Path & "\Reporte.txt"
Open App.Path & "\Reporte.txt" For Append As #1
' */*/*/*/*/*/*/*/*/*/*/*//*/*/*/*/*/*/*/*/*/*/ ENCABEZADO
PAG = 1
Print #1, ""
Print #1, "=========================== Relacion de Entrada y Salida ==========================="
Print #1, ""
Print #1, " Fecha de Hoy : " & Format(Date, "dd/mmm/yyyy")
Print #1, Space(61) & "Pagina:"; PAG
Print #1, "Codigo. "
Print #1, "Nombre Completo : "
Print #1, "Fecha Entrada Salida"
sql = " Select empleado.codigo,empleado.paterno,historial.codigo,historial.fechas,historial.entrada,historial.salida"
sql = sql + " from empleado INNER JOIN historial on empleado.codigo=historial.codigo "
sql = sql + " where historial.fechas between #" & MaskEdBox1 & "# and #" & MaskEdBox2 & "#"
Set rs = Con.datos.Execute(sql)
If rs.RecordCount <> 0 Then
CONTA = 1
Alum = 1
While Not rs.EOF
If CONTA >= 51 Then
PAG = PAG + 1
Print #1, "*******************************************************************************"
Print #1, Chr(12)
Print #1, ""
Print #1, "=========================== Relacion del Personal ==========================="
Print #1, ""
Print #1, " Fecha de Hoy : " & Format(Date, "dd/mmm/yyyy")
Print #1, Space(61) & "Pagina:"; PAG
Print #1, ""
Print #1, "Codigo. "
Print #1, "Nombre Completo : " & rs!paterno
Print #1, "Fecha Entrada Salida"
CONTA = 1
End If
Print #1, rs!fechas & Space(5) & rs!entrada
' Print #1, "---------------------------------------------------------------------------------------------------------------------"
rs.MoveNext
CONTA = CONTA + 1
Alum = Alum + 1
Wend
Close #1
Dim RETVAL
RETVAL = Shell("c:\checador\reporte.bat", 0)
End If
End Function
que estoy mal o si me explique de mi duda ?????
Lo que kiero que salga es asi el Reporte :
Codigo : 38
Nombre : Saul
--------------------------------------------------------
Fecha | Entrada | Salida
------------------------------------------------------
02/02/2006 1:30 pm 2:45 pm
02/02/2006 7:00 am 1:00 pm
Codigo :100
Nombre : Rosal
--------------------------------------------------------
Fecha | Entrada | Salida
------------------------------------------------------
02/02/2006 1:30 pm 2:45 pm
Function Imprimir()
Dim X As Byte
Dim sql, como As String
Dim rs, rs2 As Recordset
Dim CONTA As Double
Dim PAG As Variant
Dim rs1 As Recordset
'
'Dim estados As String
'estados = "A"
MsgBox "!! Prepare la Impresora para Imprimir el Reporte !!", vbInformation + vbOKOnly, "Mensaje del sistema"
Kill App.Path & "\Reporte.txt"
Open App.Path & "\Reporte.txt" For Append As #1
' */*/*/*/*/*/*/*/*/*/*/*//*/*/*/*/*/*/*/*/*/*/ ENCABEZADO
PAG = 1
Print #1, ""
Print #1, "=========================== Relacion de Entrada y Salida ==========================="
Print #1, ""
Print #1, " Fecha de Hoy : " & Format(Date, "dd/mmm/yyyy")
Print #1, Space(61) & "Pagina:"; PAG
Print #1, "Codigo. "
Print #1, "Nombre Completo : "
Print #1, "Fecha Entrada Salida"
sql = " Select empleado.codigo,empleado.paterno,historial.codigo,historial.fechas,historial.entrada,historial.salida"
sql = sql + " from empleado INNER JOIN historial on empleado.codigo=historial.codigo "
sql = sql + " where historial.fechas between #" & MaskEdBox1 & "# and #" & MaskEdBox2 & "#"
Set rs = Con.datos.Execute(sql)
If rs.RecordCount <> 0 Then
CONTA = 1
Alum = 1
While Not rs.EOF
If CONTA >= 51 Then
PAG = PAG + 1
Print #1, "*******************************************************************************"
Print #1, Chr(12)
Print #1, ""
Print #1, "=========================== Relacion del Personal ==========================="
Print #1, ""
Print #1, " Fecha de Hoy : " & Format(Date, "dd/mmm/yyyy")
Print #1, Space(61) & "Pagina:"; PAG
Print #1, ""
Print #1, "Codigo. "
Print #1, "Nombre Completo : " & rs!paterno
Print #1, "Fecha Entrada Salida"
CONTA = 1
End If
Print #1, rs!fechas & Space(5) & rs!entrada
' Print #1, "---------------------------------------------------------------------------------------------------------------------"
rs.MoveNext
CONTA = CONTA + 1
Alum = Alum + 1
Wend
Close #1
Dim RETVAL
RETVAL = Shell("c:\checador\reporte.bat", 0)
End If
End Function
que estoy mal o si me explique de mi duda ?????
Valora esta pregunta


0