Sub Main() ImprimeRemision End Sub Public Sub ImprimeRemision() ' Creamos el recordSet del encabezado de la venta Set rstEncabezado = rst("SELECT * FROM ventas WHERE venta = " & prn.Documento, Ambiente.Connection) ' Creamos el recordSet de las partidas que componen la venta Set rstPartidas = rst("SELECT * FROM partvta WHERE venta = " & rstEncabezado("Venta"), Ambiente.Connection) ' Traemos todos los datos del cliente Set rstCliente = rst("SELECT * FROM clients WHERE cliente = '" & rstEncabezado("Cliente") & "'", Ambiente.Connection) ' Los datos de la moneda Set rstMoneda = rst("SELECT * FROM monedas WHERE moneda = '" & rstEncabezado.Fields("Moneda") & "'", Ambiente.Connection) ' Los datos del vendedor Set rstVendedor = rst("SELECT * FROM vends WHERE vend = '" & rstEncabezado.Fields("vend") & "'", Ambiente.Connection) 'Indicamos cual es la impresora que deseamos utilizar EstableceImpresora Ambiente.rstEstacion("ImpRem") PaperSize 256,8.5,11,"REMISIONES" ' Iniciamos la Impresión del encabezado de la forma IniciaDocumento ' Colocamos en una variable si el movimiento esta vivo o cancelado If rstEncabezado("Estado") = "CA" Then Estado = "CANCELADO" End If If rstEncabezado("Estado") = "CO" Then Estado = "FACTURADO" End If EstableceFuente "Times New Roman",21.75 FontBold Verdadero FontItalic Falso ColorDeFuente 0 Say 1.78125,3.5, rstCliente("Nombre") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente -2147483630 Say 0.4895833,0.1770833, rstCliente("Calle") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente -2147483630 Say 0.7604167,0.1770833, rstCliente("Colonia") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente -2147483630 Say 0.7708333,1.895833, rstCliente("pobla") EstableceFuente "Arial",9.75 FontBold Verdadero FontItalic Falso ColorDeFuente 16711680 Say 1.010417,0.1770833, rstCliente("RFC") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 0.8020833,2.822917, rstCliente("Estado") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 1.020833,5.052083, rstCliente("cp") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 1.020833,3.875, "Código postal" EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 1.239583,0.1875, Formato( rstEncabezado("f_emision"), "dd-MMMM-yyyy" ) EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 1.25,2.166667, "Vencimiento: " EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 1.25,3.28125, rstEncabezado("F_venc") Incremento = 0 If Val2( rstEncabezado("nodesglosedetalle") ) = 0 Then While Not rstPartidas.EOF Set rstArticulo = CreaRecordSet( "SELECT * FROM prods WHERE articulo = '" & rstPartidas("articulo") & "'", Ambiente.Connection ) Set rstSeries = CreaRecordSet("SELECT * FROM series WHERE documento = 'REMISION' AND numeroDocumento = " & rstEncabezado("no_referen")& " AND articulo = '" & rstPartidas("articulo") & "'" , Ambiente.Connection) If rstArticulo("serie") <> 0 Then EstableceFuente "Arial",9.75 FontBold Verdadero FontItalic Falso ColorDeFuente 0 Say 4.479167 + Row (incremento), 4.052083, Trim( rstSeries("serie")) End If EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 2.78125 + Row( Incremento ), 0.21875,rstPartidas("Articulo") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 'Say 2.78125 + Row( Incremento ), 1.041667,rstArticulo("Descrip") Say 2.78125 + Row( Incremento ), 1.041667,rstPartidas("Observ") EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 'Say 2.78125 + Row( Incremento ), 4.552083,PadL(Formato( rstPartidas("Precio"), Ambiente.FDinero ),10) Say 1.320833 + Row( Incremento ), 3.377083,PadL(Formato( rstPartidas("Precio"), Ambiente.FDinero ),10) EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 2.78125 + Row( Incremento ), 5.260417,PadL(Formato( rstPartidas("Cantidad"), Ambiente.Formato ),10) EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 2.78125 + Row( Incremento ), 5.9375,Formato( rstPartidas("Descuento"), "% ##.00" ) EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 2.78125 + Row( Incremento ), 6.489583,PadL( Formato( rstPartidas("Precio") * (1 - ( rstPartidas("Descuento") / 100 ) ), Ambiente.FDinero ),10) EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 2.78125 + Row( Incremento ), 7.166667,PadL( Formato( rstPartidas("Precio") * (1 - ( rstPartidas("Descuento") / 100 ) ) * rstPartidas("cantidad"), Ambiente.FDinero ),10) '----------------------------------------------------------------------------------------------------------------------------------- '----------------------------------------------------------------------------------------------------------------------------------- '2011-04-01 'Jose Felix jofelchez@gmail.com 'ESTE BLOQUECITO DE CÓDIGO ES EL QUE PERMITE QUE SE REALICE EL SALTO DE PÁGINA ' if val2(Row( Incremento )) > 0.025 Then 'EN ESTE CASO, EL VALOR 0.025 ESTA EN PULGADAS. TENDRIA QUE ACER PRUEBAS PARA ENCONTRAR LA DIMENSION ÓPRIMA PARA QUE APAREZCAN TODAS LAS PARTIDAS Incremento = 1 PaginaNueva end if '----------------------------------------------------------------------------------------------------------------------------------- '----------------------------------------------------------------------------------------------------------------------------------- Incremento = Incremento + 1 rstPartidas.MoveNext Wend End If '----------------------------------------------------------------------------------------------------------------------------------- '----------------------------------------------------------------------------------------------------------------------------------- '2011-04-01 'Jose Felix jofelchez@gmail.com 'ESTE BLOQUE DE CÓDIGO MUESTRA LOS SUBTOTALES, IMPUESTO Y TOTAL. ESTABA ANTES DE LA SENTENCIA 'IF' DE LAS LINEAS DE ARRIBA. 'LO DEBEMOS COLOCAR AQUI PARA QUE SOLO APAREZCA AL PIE DEL DOCUMENTO EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 Say 8.166667,0.3333333, Letra( Round( rstEncabezado("Importe") + rstEncabezado("Impuesto"), 2 ), Trim(rstMoneda("Descrip")), True,rstMoneda.fields("Nombre") ) EstableceFuente "Courier New",12.75 FontBold Verdadero FontItalic Falso ColorDeFuente 0 Say 9.104167,6.5, PadL(Formato(rstEncabezado("Importe"), Ambiente.FDinero), 10) EstableceFuente "Courier New",12.75 FontBold Verdadero FontItalic Falso ColorDeFuente 0 Say 9.364583,6.5, PadL( Formato(rstEncabezado("Impuesto"), Ambiente.FDinero), 10 ) EstableceFuente "Courier New",14.25 FontBold Verdadero FontItalic Falso ColorDeFuente 0 Say 9.729167,6.239583, PadL( Formato(rstEncabezado("Importe") + rstEncabezado("Impuesto"), Ambiente.FDinero),10 ) EstableceFuente "Verdana",9.75 FontBold Falso FontItalic Falso ColorDeFuente 0 ImprimeTexto 7.375,0.3125, rstEncabezado("Observ") EstableceFuente "Times New Roman",9 FontBold Verdadero FontItalic Falso ColorDeFuente 65280 Say 1.645833,0.3958333, " Hola " '----------------------------------------------------------------------------------------------------------------------------------- '----------------------------------------------------------------------------------------------------------------------------------- FinDocumento End Sub Public Sub ImprimeTexto( nComenzar, nColumna, cTexto ) Dim nRenglon nLineas = CuantasLineas((cTexto)) nRenglon = 0 For n = 1 To nLineas Say nComenzar + Row(nRenglon), nColumna, strLinea(cTexto, n) nRenglon = nRenglon + 1 Next End Sub Public Function Si( bolCond, uDato1, uDato2 ) Dim nRenglon If bolCond = True Then Si = uDato1 Else Si = uDato2 End If End Function