VERSION 5.00 Begin VB.Form frmFaculty Caption = "Faculty Records" ClientHeight = 6480 ClientLeft = 165 ClientTop = 735 ClientWidth = 9180 LinkTopic = "Form2" ScaleHeight = 6480 ScaleWidth = 9180 StartUpPosition = 3 'Windows Default Begin VB.TextBox txtLname Height = 375 Index = 8 Left = 2160 TabIndex = 28 Top = 1725 Width = 2295 End Begin VB.TextBox txtRank Height = 375 Index = 7 Left = 2160 TabIndex = 26 Top = 2250 Width = 2295 End Begin VB.TextBox txtStartDate Height = 375 Index = 6 Left = 2160 TabIndex = 24 Top = 2790 Width = 2295 End Begin VB.TextBox txtMinHrs Height = 375 Index = 5 Left = 2160 TabIndex = 22 Top = 3315 Width = 2295 End Begin VB.TextBox txtONum Height = 375 Index = 3 Left = 6600 TabIndex = 20 Top = 1200 Width = 2295 End Begin VB.TextBox txtOPhone Height = 375 Index = 2 Left = 6600 TabIndex = 18 Top = 1740 Width = 2295 End Begin VB.TextBox txtMaxHrs Height = 375 Index = 1 Left = 2160 TabIndex = 16 Top = 3840 Width = 2295 End Begin VB.TextBox txtFname Height = 375 Index = 0 Left = 2160 TabIndex = 14 Top = 1200 Width = 2295 End Begin VB.CommandButton cmdExit Caption = "Exit" Height = 495 Index = 0 Left = 3360 TabIndex = 12 Top = 5040 Width = 975 End Begin VB.CommandButton cmdDelete Caption = "Delete" Height = 495 Left = 2280 TabIndex = 11 Top = 5040 Width = 975 End Begin VB.CommandButton cmdUpdate Caption = "Update" Height = 495 Left = 1200 TabIndex = 10 Top = 5040 Width = 975 End Begin VB.CommandButton cmdAdd Caption = "Add" Height = 495 Left = 120 TabIndex = 9 Top = 5040 Width = 975 End Begin VB.CommandButton cmdNavigate Caption = "Last >>" Height = 495 Index = 3 Left = 3360 TabIndex = 8 Top = 5880 Width = 975 End Begin VB.CommandButton cmdNavigate Caption = "Next >" Height = 495 Index = 2 Left = 2280 TabIndex = 7 Top = 5880 Width = 975 End Begin VB.CommandButton cmdNavigate Caption = "< Prev" Height = 495 Index = 1 Left = 1200 TabIndex = 6 Top = 5880 Width = 975 End Begin VB.CommandButton cmdNavigate Caption = "<< First" Height = 495 Index = 0 Left = 120 TabIndex = 5 Top = 5880 Width = 975 End Begin VB.CommandButton cmdExit Caption = "Exit Faculty Records" Height = 615 Index = 1 Left = 4440 TabIndex = 0 Top = 5040 Width = 3135 End Begin VB.Label lblLname Alignment = 1 'Right Justify Caption = "Last Name" Height = 255 Index = 8 Left = 240 TabIndex = 27 Top = 1830 Width = 1815 End Begin VB.Label lblRank Alignment = 1 'Right Justify Caption = "Rank" Height = 255 Index = 7 Left = 240 TabIndex = 25 Top = 2325 Width = 1815 End Begin VB.Label lblStartDate Alignment = 1 'Right Justify Caption = "Start Date" Height = 255 Index = 6 Left = 240 TabIndex = 23 Top = 2835 Width = 1815 End Begin VB.Label lblMinHrs Alignment = 1 'Right Justify Caption = "Min # of Hours to Work" Height = 255 Index = 5 Left = 240 TabIndex = 21 Top = 3330 Width = 1815 End Begin VB.Label lblONum Alignment = 1 'Right Justify Caption = "Office Room Number" Height = 255 Index = 3 Left = 4440 TabIndex = 19 Top = 1200 Width = 1815 End Begin VB.Label lblOPhn Alignment = 1 'Right Justify Caption = "Office Phone Number" Height = 255 Index = 2 Left = 4440 TabIndex = 17 Top = 1800 Width = 1815 End Begin VB.Label lblMaxHrs Alignment = 1 'Right Justify Caption = "Max # of Hours to Work" Height = 255 Index = 1 Left = 240 TabIndex = 15 Top = 3840 Width = 1815 End Begin VB.Label lblFname Alignment = 1 'Right Justify Caption = "First Name" Height = 255 Index = 0 Left = 120 TabIndex = 13 Top = 1320 Width = 1815 End Begin VB.Label lbl3 Alignment = 2 'Center Caption = "Faculty Records" BeginProperty Font Name = "MS Sans Serif" Size = 24 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 975 Left = 2640 TabIndex = 4 Top = 0 Width = 5655 End Begin VB.Label lblweb Alignment = 1 'Right Justify Caption = "http://blacksunhine.freeservers.com " Height = 255 Index = 1 Left = 4440 TabIndex = 3 Top = 6120 Width = 3135 End Begin VB.Label lblorg Alignment = 1 'Right Justify Caption = "An Aaron's Computer Services Production" Height = 255 Index = 0 Left = 4440 TabIndex = 2 Top = 5760 Width = 3135 End Begin VB.Label lblCSS Alignment = 2 'Center Caption = "CSS" BeginProperty Font Name = "Tahoma" Size = 36 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 975 Left = 120 TabIndex = 1 Top = 120 Width = 2295 End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuExit Caption = "E&xit" End End End Attribute VB_Name = "frmFaculty" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim mcnAp As Connection Dim mrsCss As Recordset Dim mbAddNew As Boolean Private Sub Form_Load() Set mcnAp = New Connection Set mrsCss = New Recordset 'Loads Database mcnAp.Open "Provider=Microsoft.Jet.OLEDB.3.51;" & _ "Data Source = C:\css\css_1.mdb" 'this is the troublesome line: 'mrsCss.Open "SELECT * FROM Faculty" 'mrsCss.Open "SELECT * FROM Faculty Orderby FACULTYLASTNAME", _ ' mcnAp, adOpenKeyset, adLockOptimistic, adCmdText LoadControls SetCommandButtons True SetNavigationButtons True End Sub Private Sub cmdExit_Click(Index As Integer) mrsCss.Close mcnAp.Close Set mrsCss = Nothing Set mcnAp = Nothing Unload frmFaculty frmMenu.Show End Sub Private Sub mnuExit_Click() mrsCss.Close mcnAp.Close Set mrsCss = Nothing Set mcnAp = Nothing Unload frmFaculty frmMenu.Show End Sub 'Loads Controls and Set Commands and Navigatin Buttons Private Sub LoadControls() With mrsCss txtFname = !FACULTYFIRSTNAME txtLname = !FACULTYLASTNAME txtRank = !FACULTYRANK txtStartDate = !FACULTYSTARTDATE txtMinHrs = !FACULTYMINHOURS txtMaxHrs = !FACULTYMAXHOURS txtONum = !FACULTYOFFICENO txtOPhone = !FACULTYOFFICEPHONE End With End Sub 'commands for the first, prev, next, last buttons Private Sub cmdNavigate_Click(Index As Integer) With mrsCss Select Case Index Case 0 .MoveFirst Case 1 .MovePrevious If .BOF Then .MoveFirst Case 2 .MoveNext If .BOF Then .MoveLast Case 3 .MoveLast End Select End With LoadControls SetCommandButtons True SetNavigationButtons True txtFname.SetFocus End Sub 'add button Private Sub cmdAddClick() mbAddNew = True ClearControls SetCommandButtons False txtFname.SetFocus End Sub 'blanks out all of the txt boxes Private Sub ClearControls() txtFname = "" txtLname = "" txtRank = "" txtStartDate = "" txtMinHrs = "" txtMaxHrs = "" txtONum = "" txtOPhone = "" End Sub 'enables and disables command buttons where apporprate Private Sub SetCommandButtons(bVal As Boolean) cmdAdd.Enabled = bVal cmdUpdate.Enabled = Not bVal cmdUpdate.Default = Not bVal cmdDelete.Enabled = bVal End Sub 'enables and disables navigational buttons where apporprate Private Sub SetNavigationButtons(bVal As Boolean) Dim i As Integer For i = 0 To 3 cmdNavigate(i).Enabled = bVal Next End Sub 'Allows you to update the record Private Sub cmdUpdate_Click() On Error GoTo ErrorHandler If ValidData Then If mbAddNew Then mrsCss.AddNew LoadRecord mrsCss.Update mbAddNew = False SetCommandButtons True SetNavigationButtons True txtFname.SetFocus End If Exit Sub ErrorHandler: DisplayErrorMsg If mrsCss.EditMode = adEditAdd Then mrsCss.CancelUpdate End Sub Private Function ValidData() As Boolean Dim strMessage As String If txtFname = "" Then txtFname.SetFocus strMessage = "You must enter a first name." ElseIf txtLname = "" Then txtLname.SetFocus strMessage = "You must enter a last name." ElseIf txtRank = "" Then txtRank.SetFocus strMessage = "You must enter a Rank." Else ValidData = True End If If Not ValidData Then MsgBox strMessage, vbOKOnly, msDialogTitle End If End Function Private Sub LoadRecord() With mrsCss !FACULTYFIRSTNAME = txtFname !FACULTYLASTNAME = txtLname !FACULTYRANK = txtRank !FACULTYSTARTDATE = txtStartDate !FACULTYMINHOURS = txtMinHrs !FACULTYMAXHOURS = txtMaxHrs !FACULTYOFFICENO = txtONum !FACULTYOFFICEPHONE = txtOPhone End With End Sub Private Sub cmdDelete_Click() On Error GoTo ErrorHandler If MsgBox("Are you sure you want to delete this record?", _ vbYesNo + vbDefaultButton2 + vbQuestion, msDialogTitle) = vbYes Then With mrsCss .Delete .MoveNext If .EOF Then .Requery .MoveLast End If LoadControls End With End If SetCommandButtons True SetNavigationButtons True txtName.SetFocus Exit Sub ErrorHandler: DisplayErrorMsg End Sub ' 'Private Sub txtFname_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' 'Private Sub txtLname_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' 'Private Sub txtRank_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' 'Private Sub txtStartDate_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' 'Private Sub txtMinHrs_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' 'Private Sub txtMaxHrs_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' 'Private Sub txtOnum_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' 'Private Sub txtOphone_Change() ' SetNavigationButtons False ' SetCommandButtons False 'End Sub ' Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyEscape Then LoadControls SetCommandButtons True SetNavigationButtons True 'who put this there? what it due? 'If mbAddNew Then mbAddNew = False End If End Sub Private Sub DisplayErrorMsg() MsgBox "Error Code: " & Err.Number & vbCrLf & _ "Description: " & Err.Description & vbCrLf & _ "Source: " & Err.Source, vbOKOnly + vbCritical, msDialogTitle End Sub