 |
04-12-2012, 12:56 PM
|
#1
|
|
Registered Member
Join Date: Nov 2011
Posts: 81
OS: xp
|
VB Retrieving Data To Print
Im working on an VB Program, in on the program it will pull data from a MS Access Table. Whe the data is retrieve from the Access table by in SELECT statement. I will need to print the data to a printer, which will be retrieve from the Access Table.
But the issue is that, how can I make all the data print on the same page. I tried to do an loop in the program to prevent this, but it seems the each data keep printing on seperate paper pages. I wont all the data to show on one page, if someone can help.
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim _print AsNewZebraPrint' This whole process start off the printing process'
Dim AccessDR As OleDb.OleDbDataReader
Dim AccessCommand AsNew OleDb.OleDbCommand
Dim AccessConnection AsNew OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= D:\Documents and Settings\Captain\My Documents\FL Lines.mdb;")
AccessCommand.CommandText = "SELECT [Part Description] FROM [FL End of Line Data] WHERE [SEQ]>=" & TextBox1.Text & " and [SEQ]<=" & TextBox2.Text & " "
AccessCommand.Connection = AccessConnection
AccessConnection.Open()
AccessDR = AccessCommand.ExecuteReader
While AccessDR.Read
_print.StartWrite("//10.53.252.78//YFTEST") 'Inorder to print from the printer, must input the following code'
_print.Write("^XA")
_print.Write("^SZ1^JMA")
_print.Write("^MCY^PMN")
_print.Write("^PW802~JSN")
_print.Write("^JZY")
_print.Write("^LH0,0^LRN")
_print.Write("^XZ")
_print.Write("^XA")
_print.Write("^FT240,50")
_print.Write("^CI0")
_print.Write("^A0N,14,16^FDHMMA Rack ID:^FS")
_print.Write("^FT230,75")
_print.Write("^A0N,14,16^FDLine Feed:^FS")
_print.Write("^FT230,95")
_print.Write("^A0N,24,22^FD" & (AccessDR.Item(0) & "^FS")) 'This where the data prints, but will not print all the data one one page. Seems like I need an loop or something. But can somone please help with the part.
_print.Write("^FT16,75")
_print.Write("^FT206,262")
_print.EndWrite()
EndWhile
AccessConnection.Close()
Catch ex AsException
Exit Sub
EndTry
EndSub
__________________
|
|
|
04-13-2012, 09:41 AM
|
#2
|
|
Windows Tech Team
Join Date: Jul 2010
Location: SA
Posts: 1,881
OS: DOS 3.3
|
Re: VB Retrieving Data To Print
Hi
I don't know ZPL for the Zebra printers. So not sure about all the codes you are using.
Have you tried:
Code:
PrivateSub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim _print AsNewZebraPrint' This whole process start off the printing process'
Dim AccessDR As OleDb.OleDbDataReader
Dim AccessCommand AsNew OleDb.OleDbCommand
Dim AccessConnection AsNew OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= D:\Documents and Settings\Captain\My Documents\FL Lines.mdb;")
AccessCommand.CommandText = "SELECT [Part Description] FROM [FL End of Line Data] WHERE [SEQ]>=" & TextBox1.Text & " and [SEQ]<=" & TextBox2.Text & " "
AccessCommand.Connection = AccessConnection
AccessConnection.Open()
AccessDR = AccessCommand.ExecuteReader
_print.StartWrite("//10.53.252.78//YFTEST") 'Inorder to print from the printer, must input the following code'
_print.Write("^XA")
_print.Write("^SZ1^JMA")
_print.Write("^MCY^PMN")
_print.Write("^PW802~JSN")
_print.Write("^JZY")
_print.Write("^LH0,0^LRN")
_print.Write("^XZ")
_print.Write("^XA")
_print.Write("^FT240,50")
_print.Write("^CI0")
_print.Write("^A0N,14,16^FDHMMA Rack ID:^FS")
_print.Write("^FT230,75")
_print.Write("^A0N,14,16^FDLine Feed:^FS")
_print.Write("^FT230,95")
While AccessDR.Read
_print.Write("^A0N,24,22^FD" & (AccessDR.Item(0) & "^FS")) 'This where the data prints, but will not print all the data one one page. Seems like I need an loop or something. But can somone please help with the part.
EndWhile
_print.Write("^FT16,75")
_print.Write("^FT206,262")
_print.EndWrite()
AccessConnection.Close()
Catch ex AsException
Exit Sub
EndTry
EndSub
__________________
|
|
|
04-14-2012, 07:16 AM
|
#3
|
|
Registered Member
Join Date: Nov 2011
Posts: 81
OS: xp
|
Re: VB Retrieving Data To Print
Ok, that show all the data now, but one more problem with that part.
It showing all the data on top of each other. How can I make the data show below each other?
Try
Dim _print AsNewZebraPrint' This whole process start off the printing process'
Dim AccessDR As OleDb.OleDbDataReader
Dim AccessCommand AsNew OleDb.OleDbCommand
Dim AccessConnection AsNew OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= D:\Documents and Settings\Captain\My Documents\YF Lines.mdb;")
AccessCommand.CommandText = "SELECT [Part Description] FROM [YF End of Line Data] WHERE [SEQ]>=" & TextBox1.Text & " and [SEQ]<=" & TextBox2.Text & " "
'"SELECT [Part Description] FROM [YF End of Line Data] WHERE [SEQ]>=" & TextBox1.Text & " and [SEQ]<=" & TextBox2.Text & " "
AccessCommand.Connection = AccessConnection
AccessConnection.Open()
AccessDR = AccessCommand.ExecuteReader
_print.StartWrite("//10.53.252.78//YFTEST") 'Inorder to print from the printer, must input the following code'
_print.Write("^XA")
_print.Write("^SZ1^JMA")
_print.Write("^MCY^PMN")
_print.Write("^PW802~JSN")
_print.Write("^JZY")
_print.Write("^LH0,0^LRN")
_print.Write("^XZ")
_print.Write("^XA")
_print.Write("^FT240,50")
_print.Write("^CI0")
'_print.Write("^A0N,12,14^FDHMMA Rack ID:^FS")
_print.Write("^FT230,15") ''''FOR HMMA RACK IS.. SECOND NUM MOVES UP OR DOWN....
_print.Write("^A0N,14,16^FDHMMA Rack ID:^FS")
_print.Write("^FT230,75") '''''line feed
_print.Write("^A0N,14,16^FDLine Feed:^FS")
While AccessDR.Read
_print.Write("^FT190,95") 'THE pART # ON THE TOP 2ND NUMBER MOVE LEFT _print.Write("^A0N,24,22^FD" & (AccessDR.Item(0) & "^FS")) ''''This the part I need Help In...
End While
_print.Write("^FT16,75")
_print.Write("^FT206,262") ' THIS for PHA BODY SYSTEM LOAD ID:
_print.Write("^FT16,39") ''Rack
_print.Write("^A0N,17,19^FDPHA Body Systems^FS")
_print.Write("^FT16,100") ''Rack
_print.Write("^A0N,15,17^FDRack:^FS")
_print.Write("^FT562,1186")
_print.Write("^FS^FO225,0")
_print.Write("^GB0,117,2^FS") '' straight line, that increase or decrease line.
_print.Write("^FO0,115") ' LINE THAT MOVE BY LINE FEED.. NUMBER 2 MOVES UP OR DOWN...
_print.Write("^GB780,0,2^FS")
_print.Write("^FO230,60") ' tHIS THE LINE BELOW HMMA RACK ID:
_print.Write("^GB550,0,2^FS")
_print.EndWrite()
AccessConnection.Close()
Catch ex AsException
Exit Sub
EndTry
Exit Sub
EndSub
EndClass
__________________
|
|
|
04-14-2012, 08:56 AM
|
#4
|
|
Windows Tech Team
Join Date: Jul 2010
Location: SA
Posts: 1,881
OS: DOS 3.3
|
Re: VB Retrieving Data To Print
Quote:
|
It showing all the data on top of each other.
|
meaning you need a line feed after printing each line of data?
According to your description this is a line feed
Code:
_print.Write("^FT230,75") '''''line feed
so can't you use:
Code:
While AccessDR.Read
_print.Write("^FT190,95")
_print.Write("^A0N,24,22^FD" & (AccessDR.Item(0) & "^FS"))
_print.Write("^FT230,75") '''''line feed
End While
__________________
|
|
|
04-14-2012, 09:27 AM
|
#5
|
|
Registered Member
Join Date: Nov 2011
Posts: 81
OS: xp
|
Re: VB Retrieving Data To Print
Sorry, this one one I need. It keeps stacking the data on top of each other, but it will not drop down as rows like I need. I tried to input an char return, but will not work.
While AccessDR.Read
_print.Write("^FT190,95") '
_print.Write("^A0N,24,22^FD" & (AccessDR.Item(0) & "^FS"))
End While
__________________
|
|
|
 |
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|