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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing using Printer.print (Spacing Output)

Status
Not open for further replies.

TURNERMICH

Technical User
Apr 5, 2000
64
0
0
AU
I am trying to print output to the printer so that the fields are in an aligned columns.


Printer.Print Indent & rs.Fields("title");
Printer.Print Spc(40 - Len(Trim(rs.Fields("title"))));
Printer.Print rs.Fields("quantity");
Printer.Print Spc(20 - Len(Trim(rs.Fields("quantity"))));
Printer.Print rs.Fields("comp")

No Success!!!

The output of the second column moves gradually (evenly), to the left down the page.

???Is the some sort of width command, or some other way of getting the columns aligned.
 
You might try using the .CurrentX and .CurrentY properties to "position the print head" before issuing the print statement

Something like this

printer.currentx = 100 ' or what value is appropriate
Printer.Print rs.Fields("quantity");
printer.currentx = 200 ' or appropriate value
Printer.Print rs.Fields("comp")

Another useful method to use, especially when using proportional fonts is the .TextWidth property which will tell you how much space what your string will actually require for printing. There is a corresponding .TextHeight property as well.

Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
Appreciate your comments.
Will have a look at currentx and currenty, looks like this is the answer.
 
Have had a look at textwidth.
I get eg 2075 1855 etc
How can i use this info to add spaces or ?? to the text line i am creating , to get the fields in position??
 
its espeically useful is right-justifying or centering. Lets say that you wanted to center a field and you know that the printer width of the column in which you are going to center is 3000. Then you could do something like

do while (printer.textwidth(mystring) < 3000
mystring = &quot; &quot; & mystring & &quot; &quot;
wend

or if right-justifying, if you want your text to occupy 3000 print units then

do while (printer.textwidth(mystring) < 3000
mystring = &quot; &quot; & mystring
wend

you could also pad spaces at the end of field which would automatically move the print head along. This time would only append spaces to back end.

In all cases tho, I would still set the .currenty property so that things begin where I want them to.
Good Luck
------------
Select * from Users where Clue > 0
0 rows returned
 
CajunCenturion

Thanks for your advice, i will give the textwidth way a go, later today.

Appreciate your promt advice


regards turnermich
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top