Employee Class Public Function GetEmployee(EmpID) Dim Conn As New ADODB.Connection If IsNumeric(EmpID) = False Then Err.Raise vbObjectError + 1, "SampleServer", _ "Employee ID must be passed as a number!" End If Conn.Open "EmpsDatabase", "Admin", "" Set GetEmployee = Conn.Execute("select * from tblEmps where " _ & "EmpID = " & EmpID) If GetEmployee.EOF Then Err.Raise vbObjectError + 2, "SampleServer", _ "No employee record was found!" End If End Function Public Function AddEmployee(LastName, FirstName, DepartmentID, Salary, BirthDate) If IsNumeric(DepartmentID) = False Then Err.Raise vbObjectError + 3, "SampleServer", _ "Department ID must be passed as a number!" ElseIf IsNumeric(Salary) = False Then Err.Raise vbObjectError + 4, "SampleServer", _ "Salary must be passed as a number!" ElseIf IsDate(BirthDate) = False Then Err.Raise vbObjectError + 5, "SampleServer", _ "BirthDate must be passed as a date!" Else Dim Conn As New ADODB.Connection Dim RSEmpID As ADODB.Recordset Conn.Open "EmpsDatabase", "Admin", "" Conn.Execute "insert into tblEmps (LastName, FirstName, DepartmentID, " _ & "Salary, BirthDate) values (" _ & "'" & LastName & "', " _ & "'" & FirstName & "', " _ & DepartmentID & ", " _ & Salary & ", " _ & "'" & BirthDate & "')" Set RSEmpID = Conn.Execute("select Max(EmpID) as MaxID from tblEmps") AddEmployee = RSEmpID("MaxID") End If End Function Public Sub EditEmployee(EmpID, LastName, FirstName, DepartmentID, Salary, BirthDate) If IsNumeric(EmpID) = False Then Err.Raise vbObjectError + 1, "SampleServer", _ "Employee ID must be passed as a number!" ElseIf IsNumeric(DepartmentID) = False Then Err.Raise vbObjectError + 3, "SampleServer", _ "Department ID must be passed as a number!" ElseIf IsNumeric(Salary) = False Then Err.Raise vbObjectError + 4, "SampleServer", _ "Salary must be passed as a number!" ElseIf IsDate(BirthDate) = False Then Err.Raise vbObjectError + 5, "SampleServer", _ "BirthDate must be passed as a date!" Else Dim Conn As New ADODB.Connection Dim RSEmpID As ADODB.Recordset Conn.Open "EmpsDatabase", "Admin", "" Set RSEmpID = Conn.Execute("select EmpID from tblEmps where " _ & "EmpID = " & EmpID) If RSEmpID.EOF Then Err.Raise vbObjectError + 2, "SampleServer", _ "No such employee record was found to edit!" End If Conn.Execute "Update tblEmps set " _ & "LastName = '" & LastName & "', " _ & "FirstName = '" & FirstName & "', " _ & "DepartmentID = " & DepartmentID & ", " _ & "Salary = " & Salary & ", " _ & "BirthDate = '" & BirthDate & "' " _ & "where EmpID = " & EmpID End If End Sub Public Sub DeleteEmployee(EmpID) Dim Conn As New ADODB.Connection If IsNumeric(EmpID) = False Then Err.Raise vbObjectError + 1, "SampleServer", _ "Employee ID must be passed as a number!" End If Conn.Open "EmpsDatabase", "Admin", "" Conn.Execute "Delete from tblEmps where EmpID = " & EmpID End Sub Public Function FormWithFields(EmpID, FormAction, PostGet) If IsNumeric(EmpID) = False Then Err.Raise vbObjectError + 1, "SampleServer", _ "Employee ID must be passed as a number!" End If Dim Conn As New ADODB.Connection Dim RSEmp As ADODB.Recordset Conn.Open "EmpsDatabase", "Admin", "" Set RSEmp = Conn.Execute("select * from tblEmps where " _ & "EmpID = " & EmpID) If RSEmp.EOF Then Err.Raise vbObjectError + 2, "SampleServer", _ "No such employee record was found to edit!" End If FormWithFields = "
" End Function Public Function EmpInfo(EmpID) If IsNumeric(EmpID) = False Then Err.Raise vbObjectError + 1, "SampleServer", _ "Employee ID must be passed as a number!" End If Dim Conn As New ADODB.Connection Dim RSEmp As ADODB.Recordset Conn.Open "EmpsDatabase", "Admin", "" Set RSEmp = Conn.Execute("select * from tblEmps where " _ & "EmpID = " & EmpID) If RSEmp.EOF Then Err.Raise vbObjectError + 2, "SampleServer", _ "No such employee record was found to edit!" End If EmpInfo = "Employee ID: " & RSEmp("EmpID") & "" _ & MyField.Name & " | " Next GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "
" _ & RSEmps(MyField.Name) & " | " Next GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "