# Printing Single Record using Datareport & VB6



## mdass79 (Apr 17, 2009)

Greetings!

I'm developing a small-scale Payroll System for academic purposes. I need to print individual salary slips according to the employee number that is keyed-in. 

However, when I use DataReport in VB6. It prints all records from my database in one page. How can I display pay information of one employee per page (so I can print 10 payslip for 10 employees)?

Here's what I've done so far:

'+++++In a shared module++++

Public c As New ADODB.Connection
Public r As New ADODB.Recordset
Public myId as Integer

Public Sub myConn()
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\data.mdb"
r.Open "empinfo", c, adOpenDynamic, adLockOptimistic
myId=0
End Sub

'+++++++Entering Employee ID++++++++++
Private Sub Form_Load()
myConn
End Sub
Private Sub cmdEnter_Click()
Do While Not r.EOF
If txtEmpID = r.Fields(0) Then
yFlag = True
Exit Do
End If
r.MoveNext
Loop
If yFlag Then
myId = Val(txtEmpID)
frmEmpLog.Hide
disGuest
MsgBox "You can now view your pay slip"

Else
MsgBox "Employee do not exist"
r.MoveFirst
End If
End Sub

'++++++Data Report "reportSlip.Dsr"++++
' it is properly connected to the database "data.mdb"

'++++++In mdiForm menu option++++++++
Private Sub mnuSlip_Report_Click()
reportSlip.Show
End Sub

Any response is sincerely appreciated.

Regards,
mdass79


----------

