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 = "
" FormWithFields = FormWithFields & _ "" FormWithFields = FormWithFields _ & "First Name:

" FormWithFields = FormWithFields _ & "Last Name:

" FormWithFields = FormWithFields _ & "Department ID:

" FormWithFields = FormWithFields _ & "Salary:

" FormWithFields = FormWithFields _ & "Birth Date:

" FormWithFields = 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") & "
" EmpInfo = EmpInfo & "First Name: " & RSEmp("FirstName") & "
" EmpInfo = EmpInfo & "Last Name: " & RSEmp("LastName") & "
" EmpInfo = EmpInfo & "Department: " & RSEmp("DepartmentID") & "
" EmpInfo = EmpInfo & "Salary: " & FormatCurrency(RSEmp("Salary")) & "
" EmpInfo = EmpInfo & "Birth Date: " & RSEmp("BirthDate") & "
" End Function Employees Class Public Function GetAllEmployees() Dim Conn As New ADODB.Connection Conn.Open "EmpsDatabase", "Admin", "" Set GetAllEmployees = Conn.Execute("select * from tblEmps") End Function Public Function LastNameRecords(LastNameLike) Dim Conn As New ADODB.Connection Conn.Open "EmpsDatabase", "Admin", "" Set LastNameRecords = Conn.Execute("select * from tblEmps " _ & "where LastName Like '*" & LastNameLike & "*'") End Function Public Function GetAllEmployeesHTMLTable() Dim Conn As New ADODB.Connection Dim RSEmps As ADODB.Recordset Dim MyField Conn.Open "EmpsDatabase", "Admin", "" Set RSEmps = Conn.Execute("select * from tblEmps") GetAllEmployeesHTMLTable = "" For Each MyField In RSEmps.Fields GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "" Next GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "" Do Until RSEmps.EOF GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "" For Each MyField In RSEmps.Fields GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "" Next GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "" RSEmps.MoveNext Loop GetAllEmployeesHTMLTable = GetAllEmployeesHTMLTable & "
" _ & MyField.Name & "
" _ & RSEmps(MyField.Name) & "
" End Function Public Function SelectControl() Dim Conn As New ADODB.Connection Dim RSEmps As ADODB.Recordset Conn.Open "EmpsDatabase", "Admin", "" Set RSEmps = Conn.Execute("select EmpID, FirstName & ' ' & LastName " _ & "as EmpName from tblEmps") SelectControl = "" End Function Public Function FormWithSelectControl(FormAction, PostGet) Dim Conn As New ADODB.Connection Dim RSEmps As ADODB.Recordset Conn.Open "EmpsDatabase", "Admin", "" Set RSEmps = Conn.Execute("select EmpID, FirstName & ' ' & LastName " _ & "as EmpName from tblEmps") FormWithSelectControl = "
EmpID:" FormWithSelectControl = FormWithSelectControl & "

" _ & "

" End Function