4 Replies - 3585 Views - Last Post: 24 December 2011 - 11:16 PM Rate Topic: -----

#1 hwkong1688  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-September 11

how to use printer.print to print all data from datagrid ?

Posted 24 December 2011 - 01:29 AM

Hi,
Now I only can print selected row from datagrid, how to print all row from datagrid when I click the checkbox (print all)??

see attachment

Private Sub Print2_Click()

If COM1.Value = True Then
MSComm1.CommPort = 1
Else
COM1.Value = False
LPT1.Value = True
End If

If LPT1.Value = False Then
    MSComm1.PortOpen = True
    
If MSComm1.DSRHolding = False Then
    MsgBox "Printer Not Ready", vbCritical, "Error"
    MSComm1.PortOpen = False
    Exit Sub
End If
End If

If MsgBox("      Are you sure to print", vbOKCancel, "Print") = vbCancel Then
Exit Sub
End If

text1.text = rs.field("code1")
qtty = Format$(Val(Qtytxt2.Text), "0000")

If LPT1.Value = True Then

Printer.Print "{D0391,0919,0360|}"
Printer.Print "{C|}"
Printer.Print "{D0391,0919,0360|}"
Printer.Print "{AX;+000,+000,+00|}"
Printer.Print "{AY;+00,0|}"
Printer.Print "{PC000;0116,0162,20,25,K,00,B|}"
Printer.Print "{RC00;" & text1.text & "|}"
Printer.Print "{XB00;0210,0200,A,3,03,0,0144,+0000000000,000,0,00|}"
Printer.Print "{RB00;>5>8>6" & text1.text & "|}"
Printer.Print "{XS;I," & qtty & ",0002C6200|}"

Printer.EndDoc

Else

Printer.Print "{D0391,0919,0360|}"
Printer.Print "{C|}"
Printer.Print "{D0391,0919,0360|}"
Printer.Print "{AX;+000,+000,+00|}"
Printer.Print "{AY;+00,0|}"
Printer.Print "{PC000;0116,0162,20,25,K,00,B|}"
Printer.Print "{RC00;" & text1.text & "|}"
Printer.Print "{XB00;0210,0200,A,3,03,0,0144,+0000000000,000,0,00|}"
Printer.Print "{RB00;>5>8>6" & text1.text & "|}"
Printer.Print "{XS;I," & qtty & ",0002C6200|}"

Printer.EndDoc

End If

End Sub


Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: how to use printer.print to print all data from datagrid ?

#2 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: how to use printer.print to print all data from datagrid ?

Posted 24 December 2011 - 10:55 AM

Where's the part of the code where you get the line from your datagrid?
Was This Post Helpful? 0
  • +
  • -

#3 hwkong1688  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-September 11

Re: how to use printer.print to print all data from datagrid ?

Posted 24 December 2011 - 07:21 PM

Sorry wrong code from previous..

text1.text and text2.text is link to my data field
qtytxt.text is quantity for this label format

this the mycode:

Private Sub Print1_Click()

If COM1.Value = True Then
MSComm1.CommPort = 1
Else
COM1.Value = False
LPT1.Value = True
End If

If LPT1.Value = False Then
MSComm1.PortOpen = True
If MSComm1.DSRHolding = False Then
    MsgBox "Printer Not Ready", vbCritical, "Error"
    MSComm1.PortOpen = False
    Exit Sub
End If
End If

If MsgBox("      Are you sure to print", vbOKCancel, "Print") = vbCancel Then
Exit Sub
End If

qtty = Format$(Val(qtytxt.Text), "0000")

'Only print 1 label
If LPT1.Value = True Then

'this is a label format
Printer.Print "{D0391,0919,0360|}"
Printer.Print "{C|}"
Printer.Print "{D0391,0919,0360|}"
Printer.Print "{AX;+000,+000,+00|}"
Printer.Print "{AY;+00,0|}"
Printer.Print "{PC000;0007,0144,15,20,K,00,B|}"
Printer.Print "{RC00;" & Text1.Text & "|}"
Printer.Print "{XB00;0030,0190,A,3,03,0,0149,+0000000000,000,0,00|}"
Printer.Print "{RB00;>5>8>6" & Text1.Text & "|}"
Printer.Print "{XB01;0706,0035,A,3,02,0,0142,+0000000000,000,0,00|}"
Printer.Print "{RB01;>5>8>6" & Text2.Text & "|}"
Printer.Print "{PC001;0718,0320,10,20,K,00,B|}"
Printer.Print "{RC01;" & Text2.Text & "|}"
Printer.Print "{XS;I," & qtty & ",0002C6200|}"

Printer.EndDoc

End If


Was This Post Helpful? 0
  • +
  • -

#4 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: how to use printer.print to print all data from datagrid ?

Posted 24 December 2011 - 11:09 PM

I will refer you back to the question in my previous post.
Was This Post Helpful? 0
  • +
  • -

#5 hwkong1688  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-September 11

Re: how to use printer.print to print all data from datagrid ?

Posted 24 December 2011 - 11:16 PM

This code is only can print 1 of the row datagrid i selected, if i want to print all the row in datagrid??

Private Sub Print2_Click()

Dim i As Integer

For i = 0 To DataGrid1.Columns.Count - 1
DataGrid1.Col = i

Printer.Print DataGrid1.Text

Next

Printer.EndDoc



Was This Post Helpful? 0
  • +
  • -

Page 1 of 1