473,387 Members | 1,374 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to calculate the increment percent of the salary

I am using 2 froms i.e salaryinfo is the main form, and salaryincrement is the subform. By selecting the empno i hv to enter his joining salary i.e.totalctc . If there is any increment then i hv to enter the revisedctc in the subform because in a company there is 2 increments per year.I used this code but i am getting error i.e when i finished the percentage calculation for 1st increment it is giving correctly, after that it has to close the form.like............


Private Sub IncrementPercent_LostFocus()
Dim temp As String
Dim Emp As String
Dim tctc As String
Set conn = CurrentProject.Connection
Set rst = New ADODB.Recordset
Set RST1 = New ADODB.Recordset
Set RST2 = New ADODB.Recordset

Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = conn
.Source = "SELECT Distinct EmpNo,TotalCTC FROM SalaryInfo"
.Open
End With

If Not rs.EOF Then
rs.MoveFirst
Do Until rs.EOF
tctc = rs.Fields("TotalCTC")
Emp = rs.Fields("Empno")
rst.Open "select * from SalaryIncrement where EmpNo='" & Emp & "'", conn
Dim CSno As String
Dim PSno As String
Dim Percent As String
If Not rst.EOF Then
rst.MoveFirst
Do Until rst.EOF
If DCount(rst.Fields("SId"), "SalaryIncrement", "[EmpNo]='" & Emp & "'") = 0 Then
Exit Sub

ElseIf DCount(rst.Fields("SId"), "SalaryIncrement", "[EmpNo]='" & Emp & "'") = 1 Then
'PSno = rst.Fields("SId")
RST1.Open "select RevisedCTC from SalaryIncrement where SId=" & PSno & " andEmpNo='" & Emp & "'", conn
'RST1.Open "select Max(RevisedCTC) from SalaryIncrement where EmpNo='" & Emp & "' group by EmpNo,Year,Month,RevisedCTC order by EmpNo,RevisedCTC,Year,Month", conn
temp = (RST1.Fields("RevisedCTC") - tctc) / tctc
conn.Execute "update SalaryIncrement set IncrementPercent='" & temp & "' where SId=" & PSno & " and EmpNo='" & Emp & "'"
RST1.Close

ElseIf DCount(rst.Fields("SId"), "SalaryIncrement", "[EmpNo]='" & Emp & "'") > 1 Then
PSno = rst.Fields("SId")
CSno = PSno + 1
RST1.Open "select RevisedCTC from SalaryIncrement where SId=" & PSno & " and EmpNo='" & Emp & "'", conn
RST2.Open "select RevisedCTC from SalaryIncrement where SId=" & CSno & " and EmpNo='" & Emp & "'", conn
temp = (RST1.Fields("RevisedCTC") - RST2.Fields("RevisedCTC")) / RST2.Fields("RevisedCTC")
conn.Execute "update SalaryIncrement set IncrementPercent='" & temp & "' where SId=" & PSno & " and EmpNo='" & Emp & "'"
RST1.Close
RST2.Close
MsgBox temp
End If

rst.MoveNext
Loop
End If
rst.Close
rs.MoveNext
Loop
End If
rs.Close
conn.Close
End Sub
Nov 4 '08 #1
1 7649
mshmyob
904 Expert 512MB
First fix up your code so we can read it.

Move your 3 DIM statements that are after your rst.open command to the top. All variable dimension should be done before code.

Indent all your code so we can figure out where the END, D0 LOOP etc. statements start and end.

Put your code in the code tags.

cheers,
Nov 6 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Bill | last post by:
I have two long values that are passed in an event. I would like to calculate percent complete as an int but am not quite sure how. Do I need to convert them to doubles and then use the Math class...
4
by: dmisen | last post by:
I have data on air pollution coming from sources across the country, and control options for reducing pollution from each source. The example below shows data for: - 2 sources (plant_ID "001" and...
6
by: Programador | last post by:
I'm getting this error when running this program: Cannot calculate rate using the arguments provided Module Module1 Sub Main() Rate(360, -694.44444444444446, 244274.69178082192) End Sub
0
by: neena | last post by:
hi, Any code worked out related to this query. I am using a gridview where i have 5 columns where i used a drop down list in 1 column. Salary No_months TotalSal dropdown When i select a number...
3
by: nimda via AccessMonster.com | last post by:
hii..i'm new here and dummies in access..i create one form that count total salary.i have 3 field.let say a,b and c.c is auto calculate and will show the total of a and b.my problem is when i look...
3
ChaseCox
by: ChaseCox | last post by:
Hi all, I have a problem that I have been looking at for a couple days now and I can not quite get it to work. I would like to calculate the cumulative percent failure of a certain product in...
5
by: cecil | last post by:
Hi All, I have a report sectioned/grouped by year with number fields (i,e attendance). I would like to calculate percent difference of attendance for each year. Thanks in advance, Cecil
7
by: p0lp0l | last post by:
I'm too dummy. Pls help me... The question: Write a C program that accepts for staff of cOMPANY two data values: monthly salary (ringgit amount) and a character value for performance...
3
peeaurjee
by: peeaurjee | last post by:
hi! i have a database about the employees. I want to make an Increment system about their salary. Our company will add $100 to one employee's salary after completing his 12 months just right from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.