VERSION 5.00 Begin VB.Form frmSCrew Caption = "Scaffolding Crews" ClientHeight = 2460 ClientLeft = 60 ClientTop = 345 ClientWidth = 8940 KeyPreview = -1 'True LinkTopic = "Form1" ScaleHeight = 2460 ScaleWidth = 8940 StartUpPosition = 3 'Windows Default Begin VB.TextBox txtPRCrew Height = 315 Left = 7440 TabIndex = 10 Top = 180 Width = 1395 End Begin VB.CommandButton cmdExit Caption = "&Exit" Height = 555 Left = 7440 TabIndex = 7 TabStop = 0 'False Top = 1080 Width = 1395 End Begin VB.CommandButton cmdSave Caption = "&Save" Enabled = 0 'False Height = 555 Left = 5820 TabIndex = 5 Top = 1080 Width = 1395 End Begin VB.CommandButton cmdAdd Caption = "&Add" Height = 555 Left = 4260 TabIndex = 6 TabStop = 0 'False Top = 1080 Width = 1395 End Begin VB.TextBox txtCrewBoss Height = 315 Left = 5400 MaxLength = 30 TabIndex = 4 Top = 600 Width = 3435 End Begin VB.ListBox lstCrew Height = 2205 Left = 60 Sorted = -1 'True TabIndex = 0 Top = 120 Width = 3735 End Begin VB.Label lblPRCrew Alignment = 1 'Right Justify AutoSize = -1 'True Caption = "PR Crew #:" Height = 195 Left = 6540 TabIndex = 9 Top = 240 Width = 825 End Begin VB.Label lblInstructions Caption = "Double Click On A Scaffold Driver to Update." BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 315 Left = 4140 TabIndex = 8 Top = 1860 Width = 4695 End Begin VB.Label lblCrewId Alignment = 1 'Right Justify BorderStyle = 1 'Fixed Single BeginProperty Font Name = "MS Sans Serif" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 315 Left = 5400 TabIndex = 3 Top = 180 Width = 975 End Begin VB.Label lblName Alignment = 1 'Right Justify AutoSize = -1 'True Caption = "Scaffold Driver:" Height = 195 Left = 4245 TabIndex = 2 Top = 660 Width = 1095 End Begin VB.Label lblCrewNum Alignment = 1 'Right Justify AutoSize = -1 'True Caption = "Scaffold Crew #:" Height = 195 Left = 4155 TabIndex = 1 Top = 240 Width = 1185 End End Attribute VB_Name = "frmSCrew" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim moRSCREW As Recordset Dim mboolAdding As Boolean Private Sub cboType_Change() Call CrewLoad End Sub Private Sub cmdAdd_Click() cmdAdd.Enabled = False cmdSave.Enabled = True lstCrew.Enabled = False mboolAdding = True Call FormClear txtCrewBoss.SetFocus End Sub Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdSave_Click() cmdAdd.Enabled = True cmdSave.Enabled = False lstCrew.Enabled = True Call FormSave End Sub Private Sub Form_Activate() Dim intResponse As Integer Dim strSQL As String On Error GoTo Error_EH Exit Sub Error_EH: gstrMODULE = "FormSCrew - Module Form_Activate" Call ErrorHandler2 gstrMODULE = "" Exit Sub End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Dim ShiftDown, AltDown, CtrlDown If Shift = 4 Then Exit Sub End If ShiftDown = (Shift And vbShiftMask) > 0 AltDown = (Shift And vbAltMask) > 0 CtrlDown = (Shift And vbCtrlMask) > 0 End Sub Private Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then SendKeys "{TAB}" KeyAscii = 0 End If End Sub Private Sub Form_Load() On Error GoTo Error_EH Call CrewLoad If lstCrew.ListIndex <> -1 Then If FormFindCrew() Then Call FormShowCrew End If End If Exit Sub Error_EH: gstrMODULE = "FormSCrew - Module Form_Load" Call ErrorHandler2 gstrMODULE = "" Exit Sub End Sub Private Sub CrewLoad() Dim oRS As Recordset Dim strSQL As String Dim strLine As String On Error GoTo Error_EH strSQL = "SELECT crew_id, name from tblSC_Crew" Set oRS = New Recordset oRS.Open strSQL, goConn, adOpenForwardOnly, adLockReadOnly lstCrew.Clear Do Until oRS.EOF With lstCrew .AddItem Field2Str(oRS!Name) .ItemData(.NewIndex) = oRS!crew_id End With oRS.MoveNext Loop If lstCrew.ListCount Then lstCrew.ListIndex = 0 Else lstCrew.ListIndex = -1 Call FormClear End If Exit Sub Error_EH: gstrMODULE = "FormSCrew - Module CrewLoad" Call ErrorHandler2 gstrMODULE = "" Exit Sub End Sub Private Function FormFindCrew() As Boolean Dim strSQL As String On Error GoTo Error_EH strSQL = "SELECT * " strSQL = strSQL & "FROM tblSC_crew " strSQL = strSQL & "WHERE crew_Id = " & lstCrew.ItemData(lstCrew.ListIndex) Set moRSCREW = New Recordset moRSCREW.Open strSQL, goConn, adOpenDynamic, adLockOptimistic ' adOpenKeyset , adLockOptimistic If moRSCREW.EOF Then FormFindCrew = False Else FormFindCrew = True End If Exit Function Error_EH: gstrMODULE = "FormSCrew - Module FormFindCrew" Call ErrorHandler2 gstrMODULE = "" Exit Function End Function Private Sub FormShowCrew() Dim strSQL As String Dim oRS As Recordset On Error GoTo Error_EH With moRSCREW lblCrewId.Caption = Field2Str(!crew_id) txtCrewBoss = Field2Str(!Name) txtPRCrew = Field2Str2(!prcrew) End With Exit Sub Error_EH: gstrMODULE = "FormSCrew - Module FormShowCrew" Call ErrorHandler2 gstrMODULE = "" Exit Sub End Sub Private Sub FormClear() lblCrewId.Caption = "" txtCrewBoss = "" End Sub Private Sub FieldsSave() Dim strLOT As String, test As String On Error GoTo 0 On Error GoTo Error_EH With moRSCREW !U_USER = gstrLOGIN !Update = Date !Name = Str2Field(txtCrewBoss) !prcrew = Integer2Field(txtPRCrew) End With moRSCREW.Update Call CrewLoad If mboolAdding Then Call CrewLoad If FormFindCrew() Then Call FormShowCrew End If End If Exit Sub Error_EH: If Err.Number = -2147467259 Then MsgBox "Duplicate Lot Record - This will not be saved - ReEnter", , "Duplicate Record" Resume Next End If gstrMODULE = "FormSCrew - Module FieldsSave" Call ErrorHandler2 gstrMODULE = "" Exit Sub End Sub Private Sub FormSave() Dim strName As String On Error GoTo Error_EH If mboolAdding Then moRSCREW.AddNew moRSCREW!C_USER = gstrLOGIN End If ' Store the controls to the recordset Call FieldsSave If mboolAdding Then mboolAdding = False End If Exit Sub Error_EH: Call ErrorHandler(moRSCREW.ActiveConnection) Exit Sub End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Dim intResponse As Integer, strMSG As String On Error GoTo Error_EH If cmdSave.Enabled Then strMSG = "Scaffold Crew Data Has Been Changed" strMSG = strMSG & Chr(13) & Chr(10) strMSG = strMSG & "Save Changes ?" intResponse = MsgBox(strMSG, vbQuestion + vbYesNoCancel, "Drivers") Select Case intResponse Case vbYes Call FormSave Case vbNo Case vbCancel Cancel = True Exit Sub End Select End If If moRSCREW.State = adStateOpen Then moRSCREW.Close End If Exit Sub Error_EH: If Err = 3219 Then Resume Next End If End Sub Private Sub lstCrew_Click() On Error GoTo Error_EH If lstCrew.ListIndex <> -1 Then If FormFindCrew() Then Call FormShowCrew Else lstCrew.Clear Call FormClear End If End If Exit Sub Error_EH: gstrMODULE = "Form Crews - Module lstCrew_Click" Call ErrorHandler2 gstrMODULE = "" Exit Sub End Sub Private Sub lstCrew_DblClick() If gbytSECURITY = 1 Then cmdAdd.Enabled = False cmdSave.Enabled = True txtCrewBoss.SetFocus End If End Sub Private Sub txtCrewBoss_GotFocus() Call FieldSelect(txtCrewBoss) End Sub Private Sub txtCrewBoss_LostFocus() txtCrewBoss = UCase(txtCrewBoss) End Sub