Update and Save Button code is getting error

venu_resoju

Registered User.
Local time
Tomorrow, 01:04
Joined
Dec 29, 2010
Messages
129
What's wrong with me please any body help me.

Private Sub Save_Click()

If IsNull(cboEmpName) Then
MsgBox "Please Select Employee Name"
Me.cboEmpName.SetFocus
End If
If Me.txtNoofDaysWorked.Value = "0" Then
MsgBox "Please Enter No of Worked Days"
End If
Dim db As DAO.Database
Dim rst1 As DAO.Recordset
Dim rst2 As DAO.Recordset
Set db = CurrentDb
Set rst1 = db.OpenRecordset("Payroll")
If rst1.EOF Then ' No records
rst1.AddNew
Else
rst1.Edit ' record exist
End If
rst1!PayrollID = Me!txtPayrollID
rst1!EmpID = Me!txtEmpID
rst1!EmpName = Me!cboEmpName.Column(1)
rst1!EPFNo = Me!txtEPFNo
rst1!ESINo = Me!txtESINo
rst1!NetPay = Me.txtNetPay
rst1!AdvanceBalance = Me.txtAdvRemaining
rst1.Update
rst1.Close
If Me.txtAdvance > 0 Then
Set rst2 = db.OpenRecordset("LoanTransactions")
If rst2.EOF Then ' No records
rst2.AddNew
Else
rst2.Edit ' record exist
End If

rst2!EmpName = Me!cboEmpName.Column(1)
rst2!TransnDate = Date
rst2!TransnType = "Deduction"
rst2!Sanctions = "0"
rst2!Deductions = Me.txtAdvance
rst2!LoanName = "Salary Deduction"
rst2.Update
rst2.Close

Set rst2 = Nothing
End If
Call ClearControls
End Sub
What's wrong with me please any body help me.
 
What's wrong with me please
Probably that:

1. you are double posting - see this link

http://www.access-programmers.co.uk/forums/showthread.php?t=268378

2. you have used quote tags rather than code tags, thereby losing the indents so you code is very difficult to read

3. You haven't said what the problem is - err code and description, wrong result. Or what the code is supposed to do

4. You are assuming we are mind readers:)

Suggest resolve 2 and 3 and we'll see what can be done
 

Users who are viewing this thread

Back
Top Bottom