Go Back   Tech Support Forum > The IT Pro > Programming

VB Retrieving Data To Print

This is a discussion on VB Retrieving Data To Print within the Programming forums, part of the Tech Support Forum category. Im working on an VB Program, in on the program it will pull data from a MS Access Table. Whe


Reply
 
Thread Tools Search this Thread
Old 04-12-2012, 12:56 PM   #1
Registered Member
 
Join Date: Nov 2011
Posts: 83
OS: xp


Question

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

__________________
Focus2 is offline   Reply With Quote
Old 04-13-2012, 09:41 AM   #2
Windows Tech Team
 
Join Date: Jul 2010
Location: SA
Posts: 1,921
OS: DOS 3.3



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

__________________
AlbertMC2 is offline   Reply With Quote
Old 04-14-2012, 07:16 AM   #3
Registered Member
 
Join Date: Nov 2011
Posts: 83
OS: xp



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
__________________
Focus2 is offline   Reply With Quote
Old 04-14-2012, 08:56 AM   #4
Windows Tech Team
 
Join Date: Jul 2010
Location: SA
Posts: 1,921
OS: DOS 3.3



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
__________________
AlbertMC2 is offline   Reply With Quote
Old 04-14-2012, 09:27 AM   #5
Registered Member
 
Join Date: Nov 2011
Posts: 83
OS: xp



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

__________________
Focus2 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is on
Smilies are on
[IMG] code is on
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Post a Question


» Site Navigation
 > FAQ
  > 10.0.0.2


All times are GMT -7. The time now is 08:09 AM.


Copyright 2001 - 2014, Tech Support Forum

Windows 7 - Windows XP - Windows Vista - Trojan Removal - Spyware Removal - Virus Removal - Networking - Security - Top Web Hosts