THis is the code to print the selected persons payroll info.
Private Sub cmdPrintSel_Click()
Dim MyDate As Date
Date = Me.dt1.Value
Dim MyString As String
MyString = Me.lvwInfo.SelectedItem.Text
dt1.Value = Me.lvwInfo.ListItems(Me.lvwInfo.SelectedItem.Index).SubItems(3)
If rs.State = adStateOpen Then rs.Close
rs.Open "SELECT tblPayroll.EM_ID, tblPayroll.EM_Name, tblPayroll.Monthly_Rate, tblPayroll.dDate, tblPayroll.Bonus, tblPayroll.OvertimePay, tblPayroll.AwardTicket, tblPayroll.FineTicket, tblPayroll.pension, tblPayroll.w/Tax, tblPayroll.OtherDeductions, tblPayroll.OtherEarnings, tblPayroll.Loans, tblPayroll.TotalDeductions, tblPayroll.Medical, tblPayroll.Housing, tblPayroll.Transport, tblPayroll.Furniture, tblPayroll.Feeding, tblPayroll.Miscellaneous, tblPayroll.NetPay, tblPayroll.RemainingBalance, tblPayroll.TotalPaid, tblPayroll.LoanCollected, tblPayroll.MonthlyDeduction " & _
"FROM tblPayroll WHERE EM_ID =" & "'" & MyString & "' GROUP BY tblPayroll.EM_ID, tblPayroll.EM_Name, tblPayroll.Monthly_Rate, tblPayroll.dDate, tblPayroll.Bonus, tblPayroll.OvertimePay, tblPayroll.AwardTicket, tblPayroll.FineTicket, tblPayroll.pension, tblPayroll.w/Tax, tblPayroll.OtherDeductions, tblPayroll.OtherEarnings, tblPayroll.Loans, tblPayroll.TotalDeductions, tblPayroll.Medical, tblPayroll.Housing, tblPayroll.Transport, tblPayroll.Furniture, tblPayroll.Feeding, tblPayroll.Miscellaneous, tblPayroll.NetPay, tblPayroll.RemainingBalance, tblPayroll.TotalPaid, tblPayroll.LoanCollected, tblPayroll.MonthlyDeduction HAVING Month(dDate)='" & MyDate & "' ORDER BY tblPayroll.EM_ID;", cn, adOpenStatic, adLockOptimistic
Set drtSel.DataSource = rs
drtSel.PrintReport
drtSel.Show 1
Exit Sub
err:
MsgBox err.Description, vbCritical, "Error"
Set rs = Nothing
End Sub
THe table name is,tblPayroll. With fields,
EM_ID,EM_Name,Monthly_Rate,dDate,Bonus,OvertimePay,AwardTicket,FineTicket,pension,w/Tax,OtherDeductions,OtherEarnings,Loans,TotalDeductions,Medical,Housing,Transport,Furniture,Feeding,Miscellaneous,NetPay,RemainingBalance,TotalPaid,LoanCollected,MonthlyDeduction.
Thanks very much. Will wait for your reply. Meanwhile, i'm still trying to attach the whole project