bello gbolahan

bello gbolahan

  • NA
  • 1
  • 945

printing more than one pages of records

Mar 30 2014 7:33 AM
 i have 10 records in my table and i want  to print all the records.i was able to see only 3 records shown in page 1  of the printviewdialog and could not see the pages in the printpreview.pls help me out..Here is my code
 
 
Dim strConnection As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=c:\Users\BELLCONSULT\Documents\LOCAL GOVERN.mdb"
Dim cn As OleDb.OleDbConnection = New OleDb.OleDbConnection(strConnection)
cn.Open()
Dim db2 As New OleDb.OleDbDataAdapter("select * from ADMIN_SAL ORDER BY SF_ID ", cn)
Dim cb As New OleDb.OleDbCommandBuilder(db2)
Dim ds As New DataSet
db2.Fill(ds, "ADMIN_SAL")
Dim dt As DataTable = ds.Tables("ADMIN_SAL")
Dim row As DataRow
Dim rw = dt.Rows.Count
Dim dd As New OleDb.OleDbCommand("select * from ADMIN_SAL ORDER BY SF_ID", cn)
Dim rdr As OleDb.OleDbDataReader = dd.ExecuteReader()


For Each row In dt.Rows
rdr.Read()
nm = rdr.Item("SURNAME")
ot = rdr.Item("OTHERNAMES")
gl = rdr.Item("GRADE")
s = rdr.Item("STEP")
ba = Format(rdr.Item("BASIC"), "#,##0.00")
rn = Format(rdr.Item("RENT"), "#,##0.00")
tr = Format(rdr.Item("TRANS"), "#,##0.00")
mea = Format(rdr.Item("MEAL"), "#,##0.00")
ut = Format(rdr.Item("UTIL"), "#,##0.00")
dsr = Format(rdr.Item("D_SER"), "#,##0.00")
ent = Format(rdr.Item("ENT"), "#,##0.00")
tg = Format(rdr.Item("T_GROSS"), "#,##0.00")
pay = Format(rdr.Item("PAYE"), "#,##0.00")
nul = Format(rdr.Item("NULGE"), "#,##0.00")
ct = Format(rdr.Item("CTCS"), "#,##0.00")
ad = Format(rdr.Item("ADV"), "#,##0.00")
dpt = Format(rdr.Item("DEPOSIT"), "#,##0.00")
im = Format(rdr.Item("IMPA"), "#,##0.00")
bln = Format(rdr.Item("B_LOAN"), "#,##0.00")
td = Format(rdr.Item("T_DEDUCT"), "#,##0.00")
np = Format(rdr.Item("NET_PAY"), "#,##0.00")
  dim y1 as integer=0
y = PrintDocument1.DefaultPageSettings.Margins.Top + y1
x = PrintDocument1.DefaultPageSettings.Margins.Left + 10

e.Graphics.DrawString("LOCAL GOVERNMENT NAME", pfont, Brushes.Black, x + 300, y)
e.Graphics.DrawString("PAYSLIP FOR THE MONTH OF", Font, Brushes.Black, x + 180, y + 20) : e.Graphics.DrawString(Today, Font, Brushes.Black, x + 360, y + 20)
e.Graphics.DrawRectangle(Pens.Black, x, y + 65, 700, 270)
e.Graphics.DrawLine(Pens.Black, x + 350, y + 65, x + 350, y + 295)
e.Graphics.DrawLine(Pens.Black, x, y + 295, x + 700, y + 295)
e.Graphics.DrawString("NAME:", Font, Brushes.Black, x + 30, y + 40) : e.Graphics.DrawString(nm & "" & " " & ot, Font, Brushes.Black, x + 70, y + 40)
e.Graphics.DrawString("DEPT:", Font, Brushes.Black, x + 240, y + 40) : e.Graphics.DrawString(dept, Font, Brushes.Black, x + 280, y + 40)

e.Graphics.DrawString("GRADE:", Font, Brushes.Black, x + 360, y + 40) : e.Graphics.DrawString(gl, Font, Brushes.Black, x + 410, y + 40)
e.Graphics.DrawString("STEP:", Font, Brushes.Black, x + 480, y + 40) : e.Graphics.DrawString(s, Font, Brushes.Black, x + 530, y + 40)
e.Graphics.DrawString("GROSS", Font, Brushes.Black, x + 80, y + 75) : e.Graphics.DrawString("AMOUNT", Font, Brushes.Black, x + 240, y + 75)
e.Graphics.DrawString("DEDUCTIONS", Font, Brushes.Black, x + 80, y + 75) : e.Graphics.DrawString("AMOUNT", Font, Brushes.Black, x + 600, y + 75)

e.Graphics.DrawString("BASIC", Font, Brushes.Black, x + 80, y + 95) : e.Graphics.DrawString(ba, Font, Brushes.Black, x + 240, y + 95)
e.Graphics.DrawString("RENT", Font, Brushes.Black, x + 80, y + 1155) : e.Graphics.DrawString(rn, Font, Brushes.Black, x + 240, y + 115)
e.Graphics.DrawString("TRANSPORT", Font, Brushes.Black, x + 80, y + 135) : e.Graphics.DrawString(tr, Font, Brushes.Black, x + 240, y + 135)
e.Graphics.DrawString("MEAL", Font, Brushes.Black, x + 80, y + 155) : e.Graphics.DrawString(mea, Font, Brushes.Black, x + 240, y + 155)
e.Graphics.DrawString("UTILITY", Font, Brushes.Black, x + 80, y + 175) : e.Graphics.DrawString(ut, Font, Brushes.Black, x + 240, y + 175)
e.Graphics.DrawString("D-SERVANT", Font, Brushes.Black, x + 80, y + 195) : e.Graphics.DrawString(dsr, Font, Brushes.Black, x + 240, y + 195)
e.Graphics.DrawString("ENTERTAINMENT", Font, Brushes.Black, x + 80, y + +215) : e.Graphics.DrawString(ent, Font, Brushes.Black, x + 240, y + 215)
e.Graphics.DrawString("PAYE", Font, Brushes.Black, x + 400, y + 95) : e.Graphics.DrawString(pay, Font, Brushes.Black, x + 600, y + 95)
e.Graphics.DrawString("NULGE", Font, Brushes.Black, x + 400, y + 115) : e.Graphics.DrawString(nul, Font, Brushes.Black, x + 600, y + 115)
e.Graphics.DrawString("CTCS", Font, Brushes.Black, x + 400, y + 135) : e.Graphics.DrawString(ct, Font, Brushes.Black, x + 600, y + 135)
e.Graphics.DrawString("ADV", Font, Brushes.Black, x + 400, y + 155) : e.Graphics.DrawString(ad, Font, Brushes.Black, x + 600, y + 155)
e.Graphics.DrawString("DEPOSIT", Font, Brushes.Black, x + 400, y + 175) : e.Graphics.DrawString(dpt, Font, Brushes.Black, x + 600, y + 175)
e.Graphics.DrawString("IMPA", Font, Brushes.Black, x + 400, y + 195) : e.Graphics.DrawString(im, Font, Brushes.Black, x + 600, y + 195)
e.Graphics.DrawString("BANK LOAN", Font, Brushes.Black, x + 400, y + 215) : e.Graphics.DrawString(bln, Font, Brushes.Black, x + 600, y + 215)
y1 = y1 + 370
y = y1
Next

End Sub