Foros del Web » Programación para mayores de 30 ;) » Programación General » Visual Basic clásico »

objeto printer

Estas en el tema de objeto printer en el foro de Visual Basic clásico en Foros del Web. Hola a todos quiero imprimir una tabla de una base de datos pero en cada hoja debo poner un título, asi que cada 50 o ...
  #1 (permalink)  
Antiguo 13/05/2010, 10:35
 
Fecha de Ingreso: enero-2008
Mensajes: 366
Antigüedad: 16 años, 4 meses
Puntos: 3
objeto printer

Hola a todos

quiero imprimir una tabla de una base de datos pero en cada hoja debo poner un título, asi que cada 50 o 67 (según la orientación de la hoja) lineas doy un printer.newpage y vuelvo a poner el encabezado seguido de los siguientes registros, la primer hoja la imprime bien pero a partir de la segunda me imprime un registro por cada hoja, ubico cada registro con un printer.currentY y un printer.currentX pero como que el currentY no lo genera bien.

este es mi código:
Private Sub BTImprimir_Click()
Dim rss As Recordset
Dim cadim As String
Dim ind As Integer
Dim MM As Integer
Dim ind2 As Integer
Dim longi As Integer
Dim longi2 As Integer
Dim prueba As Integer

CommonDialog1.CancelError = True
On Error GoTo RutErr
CommonDialog1.Flags = cdlPDPrintSetup
CommonDialog1.ShowPrinter
ind = 1
Printer.Orientation = CommonDialog1.Orientation

If Printer.Orientation = 1 Then
MM = 67
Else
MM = 50
End If

sSql = "SELECT * from tabla order by clave"
Set rss = miBD.OpenRecordset(sSql)
If rss.RecordCount > 0 Then
rss.MoveLast
rss.MoveFirst

Do While Not rss.EOF

If ind = 1 Then
Printer.Print Format(Now(), "dd-mm-yyyy") & " " & Time
Printer.Print ""
Printer.FontBold = True
Printer.Print " CATALOGO DE " & UCase(CadLab)
Printer.ScaleMode = vbCharacters
Printer.CurrentY = 4
Printer.CurrentX = 0
Printer.Print "Clave"
Printer.CurrentY = 4
Printer.CurrentX = Len("Clave") + Len(rss(0)) + 1
longi2 = Printer.CurrentX
Printer.Print "Descripción"
If Tabla = "Periodo" Then
Printer.CurrentY = 4
Printer.CurrentX = Len("Descripción") + Len(rss(1)) + longi2 + 1
longi = Printer.CurrentX
Printer.Print "Abreviatura"
End If
End If
If ind > MM Then
Printer.NewPage
ind = 1
rss.MovePrevious
Else
Printer.ScaleMode = vbCharacters
Printer.FontBold = False
ind2 = ind + 4
Printer.CurrentY = ind2
Printer.CurrentX = 0
Printer.Print rss(0)
Printer.CurrentY = ind2
Printer.CurrentX = longi2
Printer.Print rss(1)
If Tabla = "Periodo" Then
Printer.CurrentY = ind2
Printer.CurrentX = longi
Printer.Print rss(2)
End If
ind = ind + 1
End If
rss.MoveNext
Loop
Printer.EndDoc
End If
RutErr:
Exit Sub
End Sub

Espero me puedan ayudar gracias
  #2 (permalink)  
Antiguo 13/05/2010, 11:24
Avatar de lokoman  
Fecha de Ingreso: septiembre-2009
Mensajes: 502
Antigüedad: 14 años, 7 meses
Puntos: 47
Respuesta: objeto printer

Hola!

Corre el programa paso a paso con F8 cuando haga el corte de la nueva pag. asi te daras cuenta por que solo te imprime 1 registro en la nueva pag.

Última edición por lokoman; 13/05/2010 a las 11:30
  #3 (permalink)  
Antiguo 13/05/2010, 15:12
 
Fecha de Ingreso: enero-2008
Mensajes: 366
Antigüedad: 16 años, 4 meses
Puntos: 3
Respuesta: objeto printer

Hola, gracias por contestar, ya resolvi el problema.

En vez de utilizar el printer.current, utilizo Tab()

Gracias otra vez.

Etiquetas: objeto
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:20.