Click here to Skip to main content
16,016,180 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hello friends
I am Sarfaraz. How are you all.
Friends few months back I developed a project (OPD Reg. in VB6 and access 2007) for a Hospital. It was just going good till they print the OPD tickets using Laser Jet Printer but now they want them to print on a DotMatrix Printer(Epson LX-300+II) using the printed tickets. When they print the OPD ticket the first ticket is being printed fine but when the 2nd ticket is being printed the printer is not being reversed so that the printing is being done at an appropriate place.
Now I am facing this problem, please help me in that. My code for the print button of the ticket is as under:

VB
Printer.CurrentX = 3000
       Printer.CurrentY = 360
       Printer.FontSize = Label10.FontSize
       Printer.FontName = Label10.FontName
       Printer.Print Label10.Caption
       'OPD
       Printer.CurrentX = 3600
       Printer.CurrentY = 800
       Printer.FontSize = Label14.FontSize
       Printer.Print Label14.Caption
       'Line
       Printer.CurrentX = 500
       Printer.CurrentY = 900
       Printer.Print "____________________________________________________________________________"
       'Rs
       Printer.FontBold = True
       Printer.FontName = "times new roman"
       Printer.FontItalic = True
       Printer.FontSize = Label16.FontSize
       Printer.CurrentX = 500
       Printer.CurrentY = 800
       Printer.Print "Rs. 5/-"

       Printer.FontBold = False
       Printer.FontItalic = False
       'time
       Printer.CurrentX = 7300
       Printer.CurrentY = 800
       Printer.Print "Time: " & Label12.Caption

       'Receipt_No
       Printer.CurrentX = 500
       Printer.CurrentY = 1300
       Printer.FontSize = Text1.FontSize
       Printer.Print Label1.Caption & " " & Text1.Text
       'Date
       Printer.CurrentX = 7300
       Printer.CurrentY = 1300
       Printer.Print "Date :" & Label11.Caption

       'Name
       Printer.CurrentX = 500
       Printer.CurrentY = 1700
       Printer.Print "Name :" & Text2.Text
       'Address
       Printer.CurrentX = 7300
       Printer.CurrentY = 1700
       Printer.Print "Address :" & Text3.Text
       'Age
       Printer.CurrentX = 500
       Printer.CurrentY = 2100
       Printer.Print "Age :" & Text4.Text
       'Sex
       Printer.CurrentX = 7300
       Printer.CurrentY = 2100
       Printer.Print "Sex :" & Combo1.Text
       'Department
       Printer.CurrentX = 500
       Printer.CurrentY = 2500
       Printer.Print "Section :" & Combo2.Text


       'Room No

       Printer.CurrentX = 7300
       Printer.CurrentY = 2500
       Printer.FontBold = True
       Printer.Print "Room No :   " & Text7.Text
       Printer.FontBold = False

       'Line
       Printer.CurrentX = 500
       Printer.CurrentY = 2600
       Printer.Print "____________________________________________________________________________"
       'R/x
        'Printer.FontBold = True
        Printer.CurrentX = 500
        Printer.CurrentY = 3000
        Printer.Print "R/x"
       'Printer.FontBold = False
       'Clean Hospital
       Printer.FontBold = False
       Printer.CurrentX = 500
       Printer.CurrentY = 12100
       Printer.Print "____________________________________________________________________________"
       'clean
       Printer.CurrentX = 1800
       Printer.CurrentY = 12400
       Printer.Print "                    This is your own Hospital,Please Keep it clean."
       Printer.EndDoc

I got some clues about the problem. First is like i need to use crystal reports while printing the form text. Second is that I need to save the data in a text file and then print it from that text file.
I do not know how to implement that please help.
Thank you
Posted
Updated 1-Apr-13 1:50am
v3

1 solution

 
Share this answer
 
Comments
sarfarazbhat 1-Apr-13 13:41pm    
Thank you so much for your help!
Now only one thing I need to check is whether it will print on dotmatrix printer. Previously i was printing text boxes like
Printer.Print textbox1.text
Printer.EndDoc
directly on the paper which was working fine on laserjet but when i was printing on dot matrix printer the first page was being printed out fine but second was not being printed at the proper place instead on the middle of the page which was the problem.

Anyways thank you so much


Sarfaraz
Aarti Meswania 2-Apr-13 0:24am    
set margin property for that issue.
just create textfile write some text and print it if margin is not proper then set this way you will get page settings then apply this setting for each page while printing from vb6
sarfarazbhat 3-Apr-13 13:34pm    
Thank you for your kind reply. I tried that also but no success. Actually i want to print the text of 4 text boxes on the form to a dot matrix printer. Now i tried to save the data of all the text boxes to a text file and try to print from text file but first page is ok but 2nd page is not printing at the specified position.
I am very badly stuck on it . Please if you can help me out.
Thank you
Sarfaraz
Aarti Meswania 4-Apr-13 1:33am    
can not solve until I check it myself
if it's problem when write all pages in a textfile & print it...
And if first page is printed well then try a trick
write 1st page in textfile & print it, then write 2nd page in that textfile(remove data of first page [over-write]) and print it

hope this trick work.
let me know trick worked or not :)
sarfarazbhat 5-Apr-13 13:15pm    
I tried this solution too but unfortunately did not work. I tried online for the last so many days but could not get any solution for this problem. I do not know what to do now. I have consulted to a person through a friend of mine in New Delhi and he will be looking if he can help. In the mean while can I have your email id so that i can send the code which I have been tried so that you may get any idea how to fix this problem.
Sorry that I am may be wasting your time if it is so I am soory and pls let me know about that.
Thank you.
Email id :sarfarazbhat@gmail.com

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900