Ver Mensaje Individual
  #3 (permalink)  
Antiguo 10/01/2005, 13:23
Avatar de mveraa
mveraa
 
Fecha de Ingreso: diciembre-2002
Ubicación: santiago-chilito
Mensajes: 1.931
Antigüedad: 21 años, 4 meses
Puntos: 2
bueno tienes que modificar la sentencia sql a algo select * from tabla
nota:este codigo saca los datos de un sqlserver


' imprimir de los de la bd

Dim objErr As ADODB.Error
Dim objNewReg2 As ADODB.Recordset
Set objComm.ActiveConnection = objConn


a1 = "SELECT a.fechavenc , a.nvnumero,a.FECHA,a.estado,b.vendes,a.folio,a.tot al,c.cvedes FROM softland.iw_gsaen a , "
a2 = " softland.cwtvend b , softland.cwtconv c "
a3 = " WHERE b.vencod=a.CODVENDEDOR and tipo='F' and (estado='V' or estado='P') and a.condpago=c.cvecod "
a4 = " AND a.fecha BETWEEN '" & bus_facturas.DTPicker1 & "' AND '" & bus_facturas.DTPicker2 & "' "
a5 = " ORDER BY b.vendes,a.FECHa desc "

objComm.CommandText = a1 & a2 & a3 & a4 & a5

objComm.CommandType = adCmdText
objComm.CommandTimeout = 60


Set objNewReg2 = objComm.Execute
Dim au As Integer
au = 35
While Not objNewReg2.EOF 'imprime hasta el fin de la sql
If activado = 1 Then
Imprime 190, 10, "PAG. " & Printer.Page
End If


Imprime 10, au, objNewReg2.Fields("vendes") 'imprme registro en la pos.
Imprime 60, au, objNewReg2.Fields("folio")
Imprime 80, au, objNewReg2.Fields("fecha")
Imprime 100, au, objNewReg2.Fields("fechavenc")
Imprime 140, au, objNewReg2.Fields("total")
Imprime 160, au, objNewReg2.Fields("cvedes")
Imprime 195, au, objNewReg2.Fields("estado")

au = au + 5

If au >= 250 Then

Printer.NewPage 'nueva pag.
au = 20
activado = 1
End If


objNewReg2.MoveNext


Wend


Printer.EndDoc 'envia la hoja a la impresora


un saludo.