How Do I Move The left Margin


I am trying to create some code so I can print out mailing addresses on mailing stickers. I modified the code below (that I got from this forum.) It basically will print the labels in 3 columns. Everything works fine, EXCEPT I need to move the left hand column over a bit. It is too close to the edge of the paper. The other columns are fine. They are right in the middle.

I just don’t understand how to set the left margin for printing. Any help would be greatly appreciated. Again the code below is not mine, but I have modified certain things to work with my app.


[code] dim g as Graphics
dim rs As RecordSet
dim customer as String
dim columnIndex, columnWidth as Integer
dim rowOffset, rowHeight as integer

g = OpenPrinterDialog()

// if user clicks cancel Nil
if g = NIL then
return’ true

// Set the text font and size that we want to print with

g.TextFont = “Arial”
g.TextSize = 10

// calculate how wide each column is – divided the width of page by 3

const kColumncount = 3
columnWidth = g.Width /kColumncount + 20

// Calculate height of each record (7 lines of text)
//rowHeight = g.TextHeight * 7
rowHeight = 62

// select customer fields from database

Dim sqlRecords as string
sqlRecords = “select * from Members”

//move to top of row of page
rowOffset = 27

// loop through records and dra page toprint out
while not rs.eof

// draws 3 records into the column
for columnIndex = 0 to kColumncount-1
  if rs.eof then
  //format data into a labels
  customer =  rs.Field("First").StringValue + " " + rs.Field("Last").StringValue +EndOfLine // have to space out "1234"
  customer = customer + rs.Field("Street").StringValue + EndOfLine // Have to space out "1234"
  //customer = customer + rs.Field("Street2").StringValue + EndOfLine // Have to space out "1234"
  customer = customer + rs.Field("Town").StringValue + ", " + rs.Field("State").StringValue + " " + rs.Field("Zip").StringValue //have to space out "1234"
  // all upper case
  customer = Uppercase(customer)
  // draw to page
  g.DrawString customer,  columnIndex * columnWidth, rowOffset + g.TextAscent

//if not records then finish printing
if rs.EOF then
// finish printing that row move t next row for columns to be drawn

rowOffset = rowOffset +(rowHeight) +g.TextHeight

// if moved to end of page send to printer
if (rowOffset + 20) > g.Height then
  //send to printer and clear graphics class for next page
  //move to top of row of page
  rowOffset = 27
end if


//the last page is sent to the printer when the graphic class goes out of scope
return’ true //we handled this menu action[/code]

// draw to page g.DrawString customer, (columnIndex * columnWidth) + 10, rowOffset + g.TextAscent

Modifying this line will move all the labels 10 points to the right - adjust as you require. You could also adjust the margin in your printer setup string.

Hi Wayne,

Thanks so much for taking the time to help me. That worked great. I really appreciate it. Works perfectly now.


You’re welcome.