CUPOM NAO FISCAL

USUARIO.EXCLUIDOS 01/06/2007 15:34:36
#219395
beleza rapazes..?

olhem só!

Fiz um codigo em vb para imprimir cupom nao fiscal...
ja teste em impressora nao fiscal e funcionou beleza, imprimi na hora..

só que quando envio para impressora jato de tinta, sempre existe um atraso que tranca por uns segundos o computador total, e quando começa imprimir volta ao normal...

queria saber como solucionar esse problema...
obrigadinha..


segue o codigo abaixo completinho... quem quizer usar e melhorar fique a vontade.




  Public Function PrintCupom(Form As Form, COD_TELE As String, COD_CLIENTE As String)

Dim TBEmpresas As Recordset
Dim TBClientes As Recordset
Dim TBTele As Recordset
Dim TBTelefones As Recordset



On Error GoTo erro
Form.dlgPrint.ShowPrinter



Dim L As Double
L = 5.5

Printer.ScaleMode = 7 ' centimetros
Printer.Font = "normal"
Printer.FontSize = 9
Printer.CurrentY = 0.1
Printer.Print String(48, "=")
Printer.FontBold = True

Set TBEmpresas = BancoDeDados.OpenRecordset("select * from Empresas where ativa = 1 ")
Set TBClientes = BancoDeDados.OpenRecordset("select * from clientes where codigo_cliente = " & COD_CLIENTE & " ")
Set TBTele = BancoDeDados.OpenRecordset("select * from Tele where codigo_tele = " & COD_TELE & " ")
Set TBTelefones = BancoDeDados.OpenRecordset("select * from Telefones where codigo_cliente = " & COD_CLIENTE & " ")

If Not TBEmpresas.EOF Then
Printer.CurrentY = 0.5
Printer.CurrentX = (Printer.TextWidth(String(48, "=")) / 2) - (Printer.TextWidth(" " & TBEmpresas!razao_social & " ") / 2)
Printer.Print TBEmpresas!razao_social

End If

Printer.FontBold = False
Printer.CurrentY = 0.9
Printer.Print String(48, "=")
Printer.CurrentY = 1.3
Printer.Print "Pedido: " & COD_TELE & ""
Printer.CurrentY = 1.3
Printer.CurrentX = (Printer.TextWidth(String(48, "="))) - (Printer.TextWidth("" & Format(Now, "dd/mm/yyyy") & " - " & Format(Now, "hh:mm:ss") & ""))
Printer.Print "" & Format(Now, "dd/mm/yyyy") & " - " & Format(Now, "hh:mm:ss") & ""
Printer.CurrentY = 1.7
Printer.Print "Cód. Cliente: " & COD_CLIENTE & " "
Printer.CurrentY = 1.7
If Not TBTelefones.EOF Then
Printer.CurrentX = (Printer.TextWidth(String(48, "="))) - (Printer.TextWidth("Telefone: " & Format(TBTelefones!telefone, "(##) ####-####") & ""))
Printer.Print "Telefone: " & Format(TBTelefones!telefone, "(##) ####-####") & ""
End If
Printer.CurrentY = 2.1
Printer.Print String(48, "=")
Printer.CurrentY = 2.5
Printer.Print "Cliente: " & TBClientes!nome & " "
Printer.CurrentY = 2.9
Printer.Print "End.: " & TBClientes!Endereco & " "
Printer.CurrentY = 3.3
Printer.Print "Bairro: " & TBClientes!Bairro & " "
Printer.CurrentY = 3.7
Printer.Print "Cidade: " & LerCadastro(TBClientes!codigo_cidade, "Cidades", "codigo_cidade", "nome") & " "
Printer.CurrentY = 4.1
Printer.Print "Referencia: " & TBClientes!referencia & " " + Chr(10)
Printer.CurrentY = 4.7
Printer.Print "OBS: " & TBClientes!Obs & " "
Printer.CurrentY = 5.1
Printer.Print String(48, "=")

Printer.CurrentY = L
Printer.CurrentX = 0
Printer.Print "Produto"

Printer.CurrentY = L
Printer.CurrentX = 3.5 - Printer.TextWidth("Quant")
Printer.Print "Quant"

Printer.CurrentY = L
Printer.CurrentX = 5.5 - Printer.TextWidth("Unit.")
Printer.Print "Unit."

Printer.CurrentY = L
Printer.CurrentX = 7.5 - Printer.TextWidth("Total")
Printer.Print "Total"

Printer.Print String(48, "=")

L = L + 0.8

Dim i As Integer
Do While Not TBTele.EOF

Printer.CurrentY = L
Printer.CurrentX = 0
Printer.Print " " & LerCadastro(TBTele!codigo_produto, "Produtos", "codigo", "descricao") & ""

Printer.CurrentY = L
Printer.CurrentX = 3.3 - Printer.TextWidth("" & Format(TBTele!quantidade, "##00") & "")
Printer.Print " " & Format(TBTele!quantidade, "##00") & " "

Printer.CurrentY = L
Printer.CurrentX = 5.5 - Printer.TextWidth("" & Format(TBTele!valor_tele, "###,##0.00") & "")
Printer.Print " " & Format(TBTele!valor_tele, "###,##0.00") & " "

Printer.CurrentY = L
Printer.CurrentX = 7.4 - Printer.TextWidth("" & Format(TBTele!valor_tele * TBTele!quantidade, "###,##0.00") & "")
Printer.Print " " & Format(TBTele!valor_tele * TBTele!quantidade, "###,##0.00") & " "
Dim TOTALGERAL As Long
TOTALGERAL = TOTALGERAL + (TBTele!valor_tele * TBTele!quantidade)
L = L + 0.5

TBTele.MoveNext
Loop

L = L + 0.3

Printer.Print String(48, "=")
Printer.CurrentY = L
Printer.Print "Total Geral: "
Printer.CurrentY = L
Printer.CurrentX = 7.5 - Printer.TextWidth("" & Format(TOTALGERAL, "R$ ###,##0.00") & "")
Printer.Print "" & Format(TOTALGERAL, "R$ ###,##0.00") & ""
Printer.Print String(48, "=")


If Dir(App.Path & "\Config.ini") <> "" Then

For i = 0 To 4
Printer.Print "" & ReadINI("TELE", "linha(" & i & ")", App.Path & "\Config.ini") & ""
Next i
Printer.Print String(48, "=") + Chr(10) + Chr(10) + Chr(10)
Printer.Print " "
End If

Printer.EndDoc


Exit Function

erro:
If (Err.Number) = 32755 Or (Err.Number) = 482 Then
Call MsgBox("Impressão cancelada pelo usuário!", vbExclamation, App.Title)
Else
Call MsgBox("A Impressão não foi concluída.", vbExclamation, App.Title)

End If
End Function

USUARIO.EXCLUIDOS 01/06/2007 21:54:28
#219432
Resposta escolhida
cara eu vi duas coisas que podem ser melhoradas e talves estejam causando a pausa.

você carrega quatro tabelas, poderia selecionar as quatro tabelas em apenas um select.

você não está fechando as tabelas ao final do procedimento.

outra coisa de você usar o printer porque você não usa o Print

Printer é acumulado em buffer até o comando Printer.endoc
Print envia direto para impressora

Tópico encerrado , respostas não são mais permitidas