I am a bit confused. If a teacher teaches more than one subject, you want to split the student fee to the amount of classes he teaches?
Where does the 50% come from?
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
I will try and figure out what you need.
Student fee is $1000.00 per month
He sees 4 teachers, splitting his fee into $250.00 per teacher
The teacher teaches one subject but with ten students
He receives $2500.00 per month from the student fees.
Is this what you are looking for?
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Student fee is $1000.00 per month
He sees 4 teachers, splitting his fee into $250.00 per teacher
I'm not sure what you mean by "other" students. In my quote, are we not covering all students? Is there more you need on the student side? If so, what?
For the calculation use the following -
Private Sub Command1_Click()
Dim xStudentFee As Integer
Dim xTotalStudents As Integer
Dim xTeacherFee As Integer
Dim xTotalTeachers As Integer
Dim x As Integer
'Get the amount the student pays per month
xStudentFee = 1000
'Get the total amount of students
xTotalStudents = 10
'Show the total student fees in text box
x = xStudentFee * xTotalStudents
Text1.Text = Format(x, "### ###.00") '$10000.00
'Get the total teachers teaching
xTotalTeachers = 5
'Get the teacher fee. 10 students in a class. 5 teachers.
xTeacherFee = x / xTotalTeachers
Text2.Text = Format(xTeacherFee, "### ###.00") '$2000.00 per teacher
End Sub
This what you needed?
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
You can use the above code I supplied to get to your answer for the 50 students per teacher. : 50 students @ $1000.00 each = $50 000.00 in total. Determine how many teachers there are and divide the $50 000.00 into all of them, lets say 10 teachers, then each gets $5 000.00.
Your quote secondly how we will calculate how many students taught by this teacher is a duplication, because in the line above you already stated that there is 50 students by the teacher.
It seems that the language is a bit of a barrier here. Use an example as I did so I can determine exactly what you need.
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
The easiest way is to add a field to your table called PaidYesNo. As soon as a student pays his fee, when updating the "receipt", this field will be updated from No to Yes.
Now search your database for all the fees paid in one month (October) where the field 'PaidYesNo' is Yes. To calculate the sum do the following. Only sample code, play around with it until you have what you need.
rsPaid.Open "SELECT * FROM MyTable WHERE DateValue(" & "'" & Date & "' AND PaidYesNo = 'Yes'"
If rsPaid.BOF = True Or rsPaid.EOF =True Then
'No records available
Exit sub
Else
Dim xCount As Integer, xTotal As Integer
xTotal = 0
For xCount = 0 To rsPaid.RecordCount
xTotal = xTotal + rsPaid!TheAmountIReceivedFieldName
rsPaid.MoveNext
Next xCount
Text1.Text = xTotal
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Rather do it in button click event. Remember to add references to ms activex data objects and do the whole connection code as well. The code supplied was only a snippet.
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Look at the code I have already supplied to you in this part -
For xCount = 0 To rsPaid.RecordCount
xTotal = xTotal + rsPaid!TheAmountIReceivedFieldName
rsPaid.MoveNext
Next xCount
Text1.Text = xTotal
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Your select statement is incorrect. The "AND" must form part of the statement.
Set rs = db.OpenRecordset("select * from fee where " & "'" & txtdate1 & "'" And "'" & txtdate2 & "'")
'Do like this -
Set rs = db.OpenRecordset("select * from fee where MyFieldNameHere = DateValue(" & "'" & txtdate1 & "') And MySecondDateFieldNameHere = DateValue(" & "'" & txtdate2 & "')")
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350
Your problem is still in your select statement. You have entered the same field "PayDate, but with two separate date values. Use the >/= signs to return the correct values.
Set rs = db.OpenRecordset("select * from fee where Paydate => DateValue(" & "'" & txtdate1 & "')"
If the date or values you want to return is between 2 dates, the following -
Set rs = db.OpenRecordset("select * from fee where Paydate => DateValue(" & "'" & txtdate1 & "') And Paydate <= DateValue(" & "'" & txtdate2 & "')")
AndreRet
Senior Poster
3,922 posts since Jan 2008
Reputation Points: 334
Solved Threads: 350