keek2a4
01-07-2008, 04:26 AM
Hello Everyone,
I need to implement a particular Function. Let me explain, with a simple example.
I have a table called tblExamDetails with four fields: StuID, Subject, Result, Status
I want to implement a function that when I change the result of a Student to Fail, it updates Status to 0 and when I change the
result of a student to Pass, it updates Status to 1. However in my database, a student can keep resitting a subject till they pass, so say if student ID "001" has resitted subject "Maths" two times and Passed the third time, it updates status = 1 for the Pass record but also updates status = 1 for the past two failed attempts.
So for example say it this is my table record:
StuID Subject Result Status
=====================
001 Maths fail 0
001 Maths fail 0
001 Maths pass 1
001 Science pass 1
001 English fail 0
After running the function, the table should be
StuID Subject Result Status
=========================
001 Maths fail 1 (this is updated)
001 Maths fail 1 (this is updated)
001 Maths pass 1 (this is updated)
001 Science pass 1
001 English fail 0
The logic I need to implement in VBA is something like this:
When result = pass then change all status to "1" WHERE stuID = this.stuID AND subject = this.subject
Can someone plz guide me on this!
Thanks very much,
I need to implement a particular Function. Let me explain, with a simple example.
I have a table called tblExamDetails with four fields: StuID, Subject, Result, Status
I want to implement a function that when I change the result of a Student to Fail, it updates Status to 0 and when I change the
result of a student to Pass, it updates Status to 1. However in my database, a student can keep resitting a subject till they pass, so say if student ID "001" has resitted subject "Maths" two times and Passed the third time, it updates status = 1 for the Pass record but also updates status = 1 for the past two failed attempts.
So for example say it this is my table record:
StuID Subject Result Status
=====================
001 Maths fail 0
001 Maths fail 0
001 Maths pass 1
001 Science pass 1
001 English fail 0
After running the function, the table should be
StuID Subject Result Status
=========================
001 Maths fail 1 (this is updated)
001 Maths fail 1 (this is updated)
001 Maths pass 1 (this is updated)
001 Science pass 1
001 English fail 0
The logic I need to implement in VBA is something like this:
When result = pass then change all status to "1" WHERE stuID = this.stuID AND subject = this.subject
Can someone plz guide me on this!
Thanks very much,