VERSION 5.00 Object = "{00025600-0000-0000-C000-000000000046}#5.2#0"; "Crystl32.OCX" Begin VB.Form frmInvPrice Caption = "Supplier Inventory Prices" ClientHeight = 5265 ClientLeft = 60 ClientTop = 345 ClientWidth = 11235 KeyPreview = -1 'True LinkTopic = "Form1" ScaleHeight = 5265 ScaleWidth = 11235 StartUpPosition = 3 'Windows Default Begin VB.CommandButton cmdPrint Caption = "Print Inv List" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 555 Left = 6780 TabIndex = 16 Top = 2400 Width = 1155 End Begin Crystal.CrystalReport crInvList Left = 10485 Top = 2535 _ExtentX = 741 _ExtentY = 741 _Version = 348160 PrintFileLinesPerPage= 60 End Begin VB.CommandButton cmdExit Caption = "&Exit" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 555 Left = 8400 TabIndex = 15 Top = 2400 Width = 1155 End Begin VB.ListBox lstInv Height = 2205 Left = 120 Sorted = -1 'True TabIndex = 14 Top = 2880 Visible = 0 'False Width = 2955 End Begin VB.CommandButton cmdDeleteInv Caption = "&Delete Inventory" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 555 Left = 10020 TabIndex = 13 Top = 1740 Width = 1155 End Begin VB.CommandButton cmdSaveInv Caption = "&Save Inventory" Enabled = 0 'False BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 555 Left = 8400 TabIndex = 11 Top = 1740 Width = 1155 End Begin VB.CommandButton cmdAddInv Caption = "&Add Inventory" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 555 Left = 6780 TabIndex = 12 Top = 1740 Width = 1155 End Begin VB.CommandButton cmdFindInv Height = 435 Left = 8700 Picture = "frmInvPrice.frx":0000 Style = 1 'Graphical TabIndex = 8 Top = 1245 Visible = 0 'False Width = 435 End Begin VB.TextBox txtPrice Alignment = 1 'Right Justify Height = 315 Left = 7620 MaxLength = 8 TabIndex = 10 Top = 1260 Width = 855 End Begin VB.TextBox txtDesc Height = 315 Left = 7620 MaxLength = 30 TabIndex = 9 Top = 840 Width = 3555 End Begin VB.TextBox txtInvNo Height = 315 Left = 7620 MaxLength = 18 TabIndex = 7 Top = 420 Width = 2625 End Begin VB.ListBox lstInventory Height = 4740 Left = 3240 Sorted = -1 'True TabIndex = 2 Top = 420 Width = 3375 End Begin VB.ListBox lstSupplier Height = 2400 Left = 120 Sorted = -1 'True TabIndex = 0 Top = 420 Width = 2955 End Begin VB.Label lblPrice Alignment = 1 'Right Justify AutoSize = -1 'True Caption = "VWP Cost:" Height = 195 Left = 6735 TabIndex = 6 Top = 1320 Width = 780 End Begin VB.Label lblDesc Alignment = 1 'Right Justify AutoSize = -1 'True Caption = "Description:" Height = 195 Left = 6675 TabIndex = 5 Top = 900 Width = 840 End Begin VB.Label lblInvNo Alignment = 1 'Right Justify AutoSize = -1 'True Caption = "Inventory #:" Height = 195 Left = 6660 TabIndex = 4 Top = 480 Width = 855 End Begin VB.Label lblInventory Caption = "Inventory Items" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 3300 TabIndex = 3 Top = 120 Width = 1815 End Begin VB.Label lblSupplier Caption = "Supplier" BeginProperty Font Name = "MS Sans Serif" Size = 9.75 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 180 TabIndex = 1 Top = 120 Width = 1095 End End Attribute VB_Name = "frmInvPrice" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Dim moRSMat As Recordset Dim mboolSHOW As Boolean Dim mboolAdding As Boolean Private Sub LoadInventory() Dim oRS As Recordset Dim strSQL As String Dim strLine As String On Error GoTo Error_EH strSQL = "SELECT Inv_no, Desc, Price from tblInvPrice WHERE sup_no = " & lstSupplier.ItemData(lstSupplier.ListIndex) Set oRS = New Recordset oRS.Open strSQL, goConn, adOpenForwardOnly, adLockReadOnly lstInventory.Clear Do Until oRS.EOF With lstInventory strLine = oRS!inv_no & vbTab & Format$(Field2Str(oRS!price), "##,##0.00") & vbTab & oRS!Desc .AddItem strLine .ItemData(.NewIndex) = oRS!inv_no End With oRS.MoveNext Loop oRS.Close If lstInventory.ListCount Then lstInventory.ListIndex = 0 End If Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub LoadSupplier() Dim oRS As Recordset Dim strSQL As String Dim strLine As String On Error GoTo Error_EH strSQL = "SELECT * FROM tblSupplier WHERE type <> 'A'" Set oRS = New Recordset oRS.Open strSQL, goConn, adOpenForwardOnly, adLockReadOnly lstSupplier.Clear Do Until oRS.EOF With lstSupplier strLine = oRS!Type & vbTab & oRS!supplier .AddItem strLine .ItemData(.NewIndex) = oRS!sup_no End With oRS.MoveNext Loop oRS.Close If lstSupplier.ListCount Then lstSupplier.ListIndex = 0 End If Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub cmdFindInv_Click() Dim oRS As Recordset Dim strSQL As String, lngFind As String On Error GoTo Error_EH strSQL = "SELECT * from tblInvtry WHERE Inv_no = " & txtInvNo.Text Set oRS = New Recordset oRS.Open strSQL, goConn, adOpenForwardOnly, adLockReadOnly If oRS.RecordCount > 0 Then With oRS txtInvNo = Field2Str(!inv_no) txtDesc = Field2Str(!Desc) txtPrice.SetFocus End With Else lstInv.Visible = True Call LoadMInventory lngFind = Field2Str(txtInvNo) ' Call ListFindItem2(lstInv, lngFind) '*** need to FIX End If oRS.Close Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub LoadMInventory() Dim oRS As Recordset Dim strSQL As String Dim strLine As String On Error GoTo Error_EH strSQL = "SELECT Inv_no, Desc from tblInvtry" Set oRS = New Recordset oRS.Open strSQL, goConn, adOpenForwardOnly, adLockReadOnly lstInv.Clear Do Until oRS.EOF With lstInv strLine = oRS!inv_no & vbTab & oRS!Desc .AddItem strLine .ItemData(.NewIndex) = oRS!inv_no End With oRS.MoveNext Loop oRS.Close If lstInv.ListCount Then lstInv.ListIndex = -1 End If Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub FormClear() txtInvNo = "" txtDesc = "" txtPrice = "" End Sub Private Function FormFind() As Boolean Dim strSQL As String On Error GoTo Error_EH strSQL = "SELECT * FROM tblInvPrice WHERE Sup_no = " & lstSupplier.ItemData(lstSupplier.ListIndex) & " AND INV_NO = " & lstInventory.ItemData(lstInventory.ListIndex) If moRSMat.State = adStateOpen Then moRSMat.Close End If moRSMat.Open strSQL, goConn, _ adOpenKeyset, adLockOptimistic If moRSMat.EOF Then FormFind = False Else FormFind = True End If Exit Function Error_EH: moRSMat.Update Resume Next End Function Private Sub FormSave() Dim strName As String On Error GoTo Error_EH If mboolAdding Then moRSMat.AddNew End If ' Store the controls to the recordset Call FieldsSave moRSMat.Update If mboolAdding Then mboolAdding = False End If Exit Sub Error_EH: Call ErrorHandler(moRSMat.ActiveConnection) Exit Sub End Sub Private Sub FormShow() On Error GoTo Error_EH mboolSHOW = True With moRSMat txtInvNo = Field2Str(!inv_no) txtDesc = Field2Str(!Desc) txtPrice = Format$(Field2Str(!price), "##,###.00") End With mboolSHOW = False Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub FieldsSave() On Error GoTo Error_EH With moRSMat !inv_no = Str2Field(txtInvNo) !Desc = Str2Field(txtDesc) !price = Str2Field(txtPrice) !sup_no = lstSupplier.ItemData(lstSupplier.ListIndex) !l_update = Now() !LUUser = gstrLOGIN End With Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub cmdAddInv_Click() cmdAddInv.Enabled = False cmdSaveInv.Enabled = True cmdDeleteInv.Enabled = False mboolAdding = True Call FormClear txtInvNo.SetFocus cmdFindInv.Visible = True End Sub Private Sub cmdDeleteInv_Click() cmdDeleteInv.Enabled = False cmdSaveInv.Enabled = False cmdAddInv.Enabled = True moRSMat.Delete Call LoadInventory End Sub Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdPrint_Click() Dim strSQL As String, strMSG As String, strSql2 As String Dim oRS As Recordset, intResponse As Integer strSQL = "SELECT * FROM tblInvPrice WHERE Sup_No = " & lstSupplier.ItemData(lstSupplier.ListIndex) Set oRS = New Recordset oRS.Open strSQL, goConn, adOpenForwardOnly, adLockReadOnly ' intCount = oRS.RecordCount strSql2 = "{tblinvprice.sup_no} = " & lstSupplier.ItemData(lstSupplier.ListIndex) strMSG = "Do you want to print to the Printer?" & vbLf & vbCr ' strMSG = strMSG & intCount & " Checks did not match - Do You Want A Report" intResponse = MsgBox(strMSG, vbYesNo, "Print to Printer") gintCOPY = 1 crInvList.ReportFileName = App.Path & "\InvListByVendor.rpt" crInvList.ReplaceSelectionFormula (strSql2) If intResponse = vbYes Then crInvList.Destination = crptToPrinter Else crInvList.Destination = crptToWindow End If crInvList.CopiesToPrinter = gintCOPY crInvList.WindowState = crptMaximized crInvList.Action = 1 crInvList.Reset ' Else ' Exit Sub ' End If End Sub Private Sub cmdSaveInv_Click() cmdSaveInv.Enabled = False cmdDeleteInv.Enabled = False cmdAddInv.Enabled = True cmdFindInv.Visible = False Call FormSave Call LoadInventory End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If Shift = 4 Then Exit Sub End If If Not cmdSaveInv.Enabled Then cmdSaveInv.Enabled = True cmdAddInv.Enabled = False End If 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() Set moRSMat = New Recordset Call LoadSupplier 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 cmdSaveInv.Enabled Then strMSG = "Data Has Been Changed" strMSG = strMSG & Chr(13) & Chr(10) strMSG = strMSG & "Save Changes ?" intResponse = MsgBox(strMSG, vbQuestion + vbYesNoCancel, Me.Caption) Select Case intResponse Case vbYes Call FormSave Case vbNo Case vbCancel Cancel = True End Select End If If moRSMat.State = adStateOpen Then moRSMat.Close End If Exit Sub Error_EH: If Err = 3219 Then Resume Next Else End If End Sub Private Sub lstInv_DblClick() Dim oRS As Recordset Dim strSQL As String On Error GoTo Error_EH strSQL = "SELECT Inv_no, Desc FROM tblInvtry where Inv_no = " & lstInv.ItemData(lstInv.ListIndex) Set oRS = New Recordset oRS.Open strSQL, goConn, adOpenForwardOnly, adLockReadOnly With oRS txtInvNo = Field2Str(!inv_no) txtDesc = Field2Str(!Desc) End With oRS.Close txtPrice.SetFocus lstInv.Visible = False Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub lstInventory_Click() On Error GoTo Error_EH If lstInventory.ListIndex <> -1 Then If FormFind() Then Call FormShow End If End If Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub lstInventory_DblClick() cmdSaveInv.Enabled = True cmdDeleteInv.Enabled = True cmdAddInv.Enabled = False End Sub Private Sub lstSupplier_Click() On Error GoTo Error_EH If lstSupplier.ListIndex <> -1 Then Call LoadInventory End If Exit Sub Error_EH: Call ErrorHandler2 Exit Sub End Sub Private Sub txtDesc_GotFocus() Call FieldSelect(txtDesc) End Sub Private Sub txtInvNo_GotFocus() Call FieldSelect(txtInvNo) End Sub Private Sub txtPrice_GotFocus() Call FieldSelect(txtPrice) End Sub