For entering data to the Add Examiner Form, I used the following validation:
Private Sub Form_Load()
datExaminer.Recordset.AddNew
End Sub
Public Function Validate() As Boolean
Validate = True
If (txtExaminerNo.Text = "") Then
MsgBox ("Examiner number has to be entered")
Validate = False
Exit Function
End If
If txtExaminerNo.Text < 100000 Then
MsgBox ("Centre number must be between 100000 and 999999")
Validate = False
Exit Function
End If
If txtExaminerNo.Text > 999999 Then
MsgBox ("Centre number must be between 100000 and 999999")
Validate = False
Exit Function
End If
If (txtSurname.Text = "") Then
MsgBox ("Surname has to be entered")
Validate = False
Exit Function
End If
If (txtForename.Text = "") Then
MsgBox ("Forename has to be entered")
Validate = False
Exit Function
End If
If (txtAddress.Text = "") Then
MsgBox ("Address has to be entered")
Validate = False
Exit Function
End If
If (txtPostCode.Text = "") Then
MsgBox ("Postcode has to be entered")
Validate = False
Exit Function
End If
End Function
For Subject Reference Code, I made sure that the Codes entered are 5 digits and unique by using a combo box to list the available options for the user to select. The user cannot alter the values in the combo box unless changes are made to the Subject table. By doing this, I am reducing the chances of errors being made during data entry by the user.
Data Being Viewed In Visual Basic:
This screenshot shows the centres which have entered candidates for UKAB examinations, which subject they have entered them for, the examiner who will be marking the paper for that particular subject and the number of candidates entered for that subject from that particular centre.
The data has been ordered by Centre No. ascending and then by Subject Code ascending. This makes it much easier to read as related data are grouped together and if editing of a record needs to take place, that record can be easily found.
To edit records, the user would select a record and press EDIT. This would open up the Add Centre form, but the selected details would already be in the relevant fields, making editing easier. Once the user has edited the record, they only have to press ADD and the record is amended in the database.
To delete records, the user would select a record and press DELETE. This would cause a message box to appear asking for conformation of the delete. Once confirmed, the record is deleted from the database.
This screenshot shows the examiner who mark papers for UKAB. Their Examiner No. Forename, Surname, Address and Postcode, Tax Deduction Flag and Subject Code.
The data has been ordered by Examiner No. ascending. This makes it much easier to read as related data are grouped together and if editing of a record needs to take place, that record can be easily found.
Under the Tax Deduction column, the value –1 means that the examiner is on a low income and will not have any tax deducted. The value 0 means that they will have 22% tax deducted from their gross pay.
To edit records, the user would select a record and press EDIT. This would open up the Add Examiner form, but the selected details would already be in the relevant fields, making editing easier. Once the user has edited the record, they only have to press ADD and the record is amended in the database.
To delete records, the user would select a record and press DELETE. This would cause a message box to appear asking for conformation of the delete. Once confirmed, the record is deleted from the database.
Report 1:
For my system, I will be printing out the relevant details for each examiner separately. This is why I have included a drop down box, so that the user can select the specific examiner they want the details for.
Once the print button is pressed, the data currently being displayed is sent to the printer to be printed. The hardcopy for this report for Examiner Number: 357862 Natasha Foster is shown below.
357862 Natasha Foster
Centre No. No. Of Scripts
46310 39
65456 65
75548 53
79995 47
Private Sub cmbExaminer_Click()
Dim ExaminerNo As String
DisplayExaminerName
If (cmbExaminer.ListIndex = 0) Then
datCentre.RecordSource = "Select CentreNumber, NumberOfCandidatesEntered From Centre Order By CentreNumber ASC"
Else
ExaminerNo = cmbExaminer.Text
datCentre.RecordSource = "Select CentreNumber, NumberOfCandidatesEntered From Centre Where ExaminerNumber = " & ExaminerNo & " Order By CentreNumber ASC"
End If
datCentre.CommandType = adCmdText
datCentre.Refresh
End Sub
Public Sub LoadExaminers()
cmbExaminer.Clear
cmbExaminer.AddItem ("All Examiners")
datExaminer.Recordset.MoveFirst
While datExaminer.Recordset.EOF = False
cmbExaminer.AddItem (datExaminer.Recordset("ExaminerNumber"))
datExaminer.Recordset.MoveNext
Wend
cmbExaminer.ListIndex = 0
End Sub
Private Sub Form_Load()
datExaminer.Refresh
LoadExaminers
End Sub
Public Sub DisplayExaminerName()
Dim ExaminerNo As String
If (cmbExaminer.ListIndex = 0) Then
lblExaminerName.Caption = cmbExaminer.Text
Else
ExaminerNo = cmbExaminer.Text
datExaminer.Recordset.MoveFirst
datExaminer.Recordset.Find ("ExaminerNumber = " & ExaminerNo)
lblExaminerName.Caption = datExaminer.Recordset("Forename") & " " & datExaminer.Recordset("Surname")
End If
Private Sub CmdPrint_Click()
'Printer.Print .Fields.Item("Centre Number").Value & vbTab & .Fields.Item("Subject Reference Code").Value & vbTab & .Fields.Item("Examiner Number").Value & vbTab & Str$(.Fields.Item("Number Of Candidates Entered").Value) & vbNewLine
rsCentre.MoveNext
End With
Wend
Printer.EndDoc
End Sub
End Function
Report 2:
Examiner: 136872
Examiner Name: Lee Wright
Admin Payment: £95
Script Rate: £3.75
Scripts Marked: 204
Gross Pay: £860.00
Tax Deducted: £189.20
Net Pay: £670.80
Private Sub cmbExaminer_Click()
Calc
End Sub
Public Sub LoadExaminers()
cmbExaminer.Clear
datExaminer.Recordset.MoveFirst
While datExaminer.Recordset.EOF = False
cmbExaminer.AddItem (datExaminer.Recordset("ExaminerNumber"))
datExaminer.Recordset.MoveNext
Wend
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Form_Load()
datExaminer.Refresh
LoadExaminers
End Sub
Public Sub DisplayExaminerName()
Dim ExaminerNo As String
ExaminerNo = cmbExaminer.Text
datExaminer.Recordset.MoveFirst
datExaminer.Recordset.Find ("ExaminerNumber = " & ExaminerNo)
lblExaminerName.Caption = datExaminer.Recordset("Forename") & " " & datExaminer.Recordset("Surname")
lblAdminPayment.Caption = "95.00"
End Sub
Private Sub cmdPrint_Click()
Printer.Print .Fields.Item("Examiner Number").Value & vbTab & .Fields.Item("Examiner Name").Value & vbTab & .Fields.Item("Admin Payment").Value & vbTab & Str$(.Fields.Item("Script Rate").Value) & vbTab & .Fields.Item("Gross Pay").Value & vbTab & .Fields.Item("Tax Deducted").Value & vbTab & Str$(.Fields.Item("Net Pay").Value) & vbNewLine
End Sub
rsCentre.MoveNext
End With
Wend
Printer.EndDoc
End Sub
Public Function ScriptRates()
datExaminer.RecordSource = "Select SubjectReferenceCode from Examiner where ExaminerNumber = " & ExaminerNo
End Function
Public Sub Calc()
Dim ExaminerNo As String
Dim TotalScriptsMarked As Long
Dim ScriptRate As Double
Dim GrossPay As Double
Dim TaxDeducted As Double
Dim NetPay As Double
DisplayExaminerName
ExaminerNo = cmbExaminer.Text
datCentre.RecordSource = "Select SubjectReferenceCode, NumberOfCandidatesEntered From Centre Where ExaminerNumber = " & ExaminerNo
datCentre.Refresh
TotalScriptsMarked = 0
' calculate the total scripts marked
datCentre.Recordset.MoveFirst
ScriptRate = GetScriptRate(datCentre.Recordset(0))
While (datCentre.Recordset.EOF = False)
TotalScriptsMarked = TotalScriptsMarked + datCentre.Recordset(1)
datCentre.Recordset.MoveNext
Wend
GrossPay = (ScriptRate * TotalScriptsMarked) + lblAdminPayment.Caption
If (GetTaxDeductedFlag() = False) Then
TaxDeducted = (GrossPay / 100) * 22
Else
TaxDeducted = 0
End If
NetPay = GrossPay - TaxDeducted
' display the total
lblGrossPay.Caption = Format(GrossPay, "£#,##0.00")
lblScriptRate.Caption = Format(ScriptRate, "£#,##0.00")
lblScriptsMarked.Caption = TotalScriptsMarked
lblTaxDeducted.Caption = Format(TaxDeducted, "£#,##0.00")
lblNetPay.Caption = Format(NetPay, "£#,##0.00")
End Sub
Public Function GetScriptRate(SubjectCode As Long) As Double
datSubject.RecordSource = "SELECT Payment FROM Subject WHERE SubjectReferenceCode = " & SubjectCode
datSubject.Refresh
GetScriptRate = datSubject.Recordset(0)
End Function
Public Function GetTaxDeductedFlag() As Boolean
Dim ExaminerNo As String
ExaminerNo = cmbExaminer.Text
datExaminer.Recordset.MoveFirst
datExaminer.Recordset.Find ("ExaminerNumber = " & ExaminerNo)
GetTaxDeductedFlag = datExaminer.Recordset("TaxDeductionFlag")
End Function
Report 3:
For my system, I will be printing out the relevant details for each subject separately. This is why I have included a drop down box, so that the user can select the specific subject they want the details for.
Below is the hardcopy of the centres entering candidates for SubjectReferenceCode: 28181 (Computer Science) and the number of candidates from each centre and the total number of candidates for that subject.
28181 Computer Science
Centre No. No. Candidates Entered Total Number Of Candidates Entered:
10001 45 818
12375 58
25487 48
25589 54
34695 49
34962 52
37951 66
46310 39
46795 35
46981 50
58746 42
65456 65
67135 48
75548 53
78998 67
79995 47
Private Sub cmbSubject_Click()
Dim SubjectCode As String
DisplaySubjectName
If (cmbSubject.ListIndex = 0) Then
datCentre.RecordSource = "Select CentreNumber, NumberOfCandidatesEntered From Centre Order By CentreNumber ASC"
datCentreTotal.RecordSource = "Select SUM(NumberOfCandidatesEntered) From Centre"
Else
SubjectCode = cmbSubject.Text
datCentre.RecordSource = "Select CentreNumber, NumberOfCandidatesEntered From Centre Where SubjectReferenceCode = " & SubjectCode & " Order By CentreNumber ASC"
datCentreTotal.RecordSource = "Select SUM(NumberOfCandidatesEntered) From Centre Where SubjectReferenceCode = " & SubjectCode
End If
datCentre.CommandType = adCmdText
datCentre.Refresh
datCentreTotal.CommandType = adCmdText
datCentreTotal.Refresh
txtTotal.Text = datCentreTotal.Recordset(0)
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Public Sub LoadSubjects()
cmbSubject.Clear
cmbSubject.AddItem ("All Subjects")
datSubject.Recordset.MoveFirst
While datSubject.Recordset.EOF = False
cmbSubject.AddItem (datSubject.Recordset("SubjectReferenceCode"))
datSubject.Recordset.MoveNext
Wend
cmbSubject.ListIndex = 0
End Sub
Private Sub Form_Load()
datSubject.Refresh
LoadSubjects
End Sub
Public Sub DisplaySubjectName()
Dim SubjectCode As String
If (cmbSubject.ListIndex = 0) Then
lblSubjectName.Caption = cmbSubject.Text
Else
SubjectCode = cmbSubject.Text
datSubject.Recordset.MoveFirst
datSubject.Recordset.Find ("SubjectReferenceCode = " & SubjectCode)
lblSubjectName.Caption = datSubject.Recordset("SubjectName")
End If
End Sub
Report 4:
For my system, I will be printing out the relevant details for each subject separately. This is why I have included a drop down box, so that the user can select the specific subject they want the details for.
Below is the hardcopy of the centres entering candidates for SubjectReferenceCode: 64773 (Economic) and examiners marking papers from this subject.
64773 Economics
Examiner No. Forename Surname Centre No.
137982 George Cloomey 10001
137982 George Cloomey 34962
137982 George Cloomey 12375
137982 George Cloomey 46981
357862 Natasha Foster 75548
357862 Natasha Foster 46310
357862 Natasha Foster 65456
357862 Natasha Foster 79995
842695 Liam Pitte 46795
842695 Liam Pitte 37951
842695 Liam Pitte 67135
842695 Liam Pitte 25589
422689 Christiano Ronaldo 34695
422689 Christiano Ronaldo 25487
422689 Christiano Ronaldo 58746
422689 Christiano Ronaldo 78998
Private Sub cmbSubject_Click()
Dim SubjectCode As String
DisplaySubjectName
If (cmbSubject.ListIndex = 0) Then
datCentre.RecordSource = "Select Centre.ExaminerNumber, Centre.CentreNumber, Examiner.Forename, Examiner.Surname From Centre, Examiner Where Centre.ExaminerNumber = Examiner.ExaminerNumber Order By Examiner.Surname ASC"
Else
SubjectCode = cmbSubject.Text
datCentre.RecordSource = "Select Centre.ExaminerNumber, Centre.CentreNumber, Examiner.Forename, Examiner.Surname From Centre, Examiner Where Centre.ExaminerNumber = Examiner.ExaminerNumber AND Centre.SubjectReferenceCode = " & SubjectCode & " Order By Examiner.Surname ASC"
End If
datCentre.CommandType = adCmdText
datCentre.Refresh
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Public Sub LoadSubjects()
cmbSubject.Clear
cmbSubject.AddItem ("All Subjects")
datSubject.Recordset.MoveFirst
While datSubject.Recordset.EOF = False
cmbSubject.AddItem (datSubject.Recordset("SubjectReferenceCode"))
datSubject.Recordset.MoveNext
Wend
cmbSubject.ListIndex = 0
End Sub
Private Sub Form_Load()
datSubject.Refresh
LoadSubjects
Private Sub cmdPrint_Click()
Printer.Print .Fields.Item("Examiner Number").Value & vbTab & .Fields.Item("Examiner Forename").Value & vbTab & .Fields.Item("Examiner Surname").Value & vbTab & Str$(.Fields.Item("Centre No.").Value) & vbNewLine
End Sub
Public Sub DisplaySubjectName()
Dim SubjectCode As String
If (cmbSubject.ListIndex = 0) Then
lblSubjectName.Caption = cmbSubject.Text
Else
SubjectCode = cmbSubject.Text
datSubject.Recordset.MoveFirst
datSubject.Recordset.Find ("SubjectReferenceCode = " & SubjectCode)
lblSubjectName.Caption = datSubject.Recordset("SubjectName")
End If
End Sub
Report 5:
This shows the number of candidates entered for each subject and the total number of candidates who are sitting UKAB exams. It also shows how much was paid to examiner for each subject and how much was paid to them in total.
Subject Code Candidates Entered Payment Made
20094 819 £3,851.16
28181 825 £2,709.53
64773 818 £6,076.73
Total: 2462 £12,637.42
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub Form_Load()
datExaminer.Refresh
datCentre.Refresh
datSubject.Refresh
Dim SubjectCode As Long
Dim ExaminerNo As Long
Dim TaxDeductedFlag As Boolean
Dim CanEnt As Long
Dim PayMade As Double
Dim EngCandidates As Long
Dim EngPaymentMade As Double
Dim CompCandidates As Long
Dim CompPaymentMade As Double
Dim EcoCandidates As Long
Dim EcoPaymentMade As Double
Dim TotalCandidates As Long
Dim TotalPaymentMade As Double
datExaminer.Recordset.MoveFirst
While (datExaminer.Recordset.EOF = False)
SubjectCode = datExaminer.Recordset("SubjectReferenceCode")
ExaminerNo = datExaminer.Recordset("ExaminerNumber")
TaxDeductedFlag = datExaminer.Recordset("TaxDeductionFlag")
Call CalcTotals(SubjectCode, ExaminerNo, TaxDeductedFlag, CanEnt, PayMade)
If (SubjectCode = 20094) Then
EngCandidates = EngCandidates + CanEnt
EngPaymentMade = EngPaymentMade + PayMade
End If
If (SubjectCode = 28181) Then
CompCandidates = CompCandidates + CanEnt
CompPaymentMade = CompPaymentMade + PayMade
End If
If (SubjectCode = 64773) Then
EcoCandidates = EcoCandidates + CanEnt
EcoPaymentMade = EcoPaymentMade + PayMade
End If
datExaminer.Recordset.MoveNext
Wend
lblCanEng.Caption = EngCandidates
lblPayEng.Caption = Format(EngPaymentMade, "£#,##0.00")
lblCanComp.Caption = CompCandidates
lblPayComp.Caption = Format(CompPaymentMade, "£#,##0.00")
blCanEco.Caption = EcoCandidates
lblPayEco.Caption = Format(EcoPaymentMade, "£#,##0.00")
lblTotalCan.Caption = EngCandidates + CompCandidates + EcoCandidates
lblTotalPay.Caption = Format(EngPaymentMade + CompPaymentMade + EcoPaymentMade, "£#,##0.00")
End Sub
Public Sub CalcTotals(ByVal SubjectCode As Long, ByVal ExaminerNo As Long, ByVal TaxDeductedFlag As Boolean, ByRef CandidatesEntered As Long, ByRef PaymentMade As Double)
Dim ScriptRate As Double
Dim TaxDeducted As Double
datCentre.RecordSource = "Select Sum(NumberOfCandidatesEntered) From Centre Where SubjectReferenceCode = " & SubjectCode & " AND ExaminerNumber = " & ExaminerNo
datCentre.Refresh
CandidatesEntered = datCentre.Recordset(0)
PaymentMade = 0
ScriptRate = GetScriptRate(SubjectCode)
PaymentMade = (CandidatesEntered * ScriptRate) + 95
TaxDeducted = 0
If (TaxDeductedFlag = False) Then
TaxDeducted = (PaymentMade / 100) * 22
End If
PaymentMade = PaymentMade - TaxDeducted
End Sub
Public Function GetScriptRate(SubjectCode As Long) As Double
datSubject.RecordSource = "SELECT Payment FROM Subject WHERE SubjectReferenceCode = " & SubjectCode
datSubject.Refresh
GetScriptRate = datSubject.Recordset("Payment")
End Function
Jeeva Thavarajah 1163 Page