Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to print all data from datagrid with loop command?

Status
Not open for further replies.

wong1983

MIS
Dec 25, 2011
1
hi,
Actually I want is when I mark checkbox [Print all] and click Print button then all data from datagrid will print out the barcode label,i want is how to loop and print all data from datagrid like my output barcode format accordingly.

I need my project urgently, thank you.

Code:
Private Sub Print1_Click()

Dim i As Integer

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")

If LPT1.Value = True Then

'LabelFormat
LabelFormat

End If
End Sub

Public Sub LabelFormat()

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 Sub
Your help is much appreciated.

below is my output barcode format:

{D0391,0919,0360|}
{C|}
{D0391,0919,0360|}
{AX;+000,+000,+00|}
{AY;+00,0|}
{PC000;0007,0144,15,20,K,00,B|}
{RC00;AA-49-4-I1|}
{XB00;0030,0190,A,3,03,0,0149,+0000000000,000,0,00|}
{RB00;>5>8>6AA-49-4-I1|}
{XB01;0706,0035,A,3,02,0,0142,+0000000000,000,0,00|}
{RB01;>5>8>67S8|}
{PC001;0718,0320,10,20,K,00,B|}
{RC01;7S8|}
{XS;I,,0002C6200|}
 

Just loop though the underlying recordset.
 
Just loop the records in the underlying recordset using
rs.MoveFirst
Do Until rs.Eof

'Print Task

rs.MoveNext
Loop
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top