home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 6_2008-2009.ISO / data / zips / Clinic_Inv2147823272009.psc / Clinic / AddStock.frm next >
Text File  |  2009-03-05  |  22KB  |  695 lines

  1. VERSION 5.00
  2. Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "comctl32.ocx"
  3. Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "Mscomct2.ocx"
  4. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "Msflxgrd.ocx"
  5. Begin VB.Form Form7 
  6.    Caption         =   "Stocks"
  7.    ClientHeight    =   6165
  8.    ClientLeft      =   60
  9.    ClientTop       =   450
  10.    ClientWidth     =   9885
  11.    ClipControls    =   0   'False
  12.    ControlBox      =   0   'False
  13.    ForeColor       =   &H00004000&
  14.    LinkTopic       =   "Form7"
  15.    ScaleHeight     =   6165
  16.    ScaleWidth      =   9885
  17.    StartUpPosition =   1  'CenterOwner
  18.    Begin VB.TextBox Text1 
  19.       Height          =   375
  20.       Left            =   6480
  21.       TabIndex        =   23
  22.       Text            =   "Text1"
  23.       Top             =   7080
  24.       Width           =   1455
  25.    End
  26.    Begin VB.Data Data2 
  27.       Caption         =   "Data2"
  28.       Connect         =   "Access"
  29.       DatabaseName    =   ""
  30.       DefaultCursorType=   0  'DefaultCursor
  31.       DefaultType     =   2  'UseODBC
  32.       Exclusive       =   0   'False
  33.       Height          =   345
  34.       Left            =   480
  35.       Options         =   0
  36.       ReadOnly        =   0   'False
  37.       RecordsetType   =   1  'Dynaset
  38.       RecordSource    =   ""
  39.       Top             =   7800
  40.       Width           =   1935
  41.    End
  42.    Begin ComctlLib.ListView ListView1 
  43.       Height          =   615
  44.       Left            =   3000
  45.       TabIndex        =   21
  46.       Top             =   7200
  47.       Width           =   2895
  48.       _ExtentX        =   5106
  49.       _ExtentY        =   1085
  50.       View            =   3
  51.       LabelWrap       =   -1  'True
  52.       HideSelection   =   -1  'True
  53.       _Version        =   327682
  54.       ForeColor       =   -2147483640
  55.       BackColor       =   -2147483643
  56.       BorderStyle     =   1
  57.       Appearance      =   1
  58.       NumItems        =   0
  59.    End
  60.    Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1 
  61.       Bindings        =   "AddStock.frx":0000
  62.       Height          =   2775
  63.       Left            =   120
  64.       TabIndex        =   20
  65.       Top             =   3000
  66.       Width           =   9615
  67.       _ExtentX        =   16960
  68.       _ExtentY        =   4895
  69.       _Version        =   393216
  70.       Cols            =   7
  71.       FixedCols       =   0
  72.       ForeColor       =   16384
  73.       Enabled         =   0   'False
  74.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  75.          Name            =   "MS Sans Serif"
  76.          Size            =   8.25
  77.          Charset         =   0
  78.          Weight          =   700
  79.          Underline       =   0   'False
  80.          Italic          =   0   'False
  81.          Strikethrough   =   0   'False
  82.       EndProperty
  83.    End
  84.    Begin VB.Data Data1 
  85.       Caption         =   "datint"
  86.       Connect         =   "Access"
  87.       DatabaseName    =   ""
  88.       DefaultCursorType=   0  'DefaultCursor
  89.       DefaultType     =   2  'UseODBC
  90.       Exclusive       =   0   'False
  91.       Height          =   375
  92.       Left            =   240
  93.       Options         =   0
  94.       ReadOnly        =   0   'False
  95.       RecordsetType   =   1  'Dynaset
  96.       RecordSource    =   ""
  97.       Top             =   7200
  98.       Width           =   2175
  99.    End
  100.    Begin VB.Frame Frame1 
  101.       Caption         =   "Adding Entry"
  102.       BeginProperty Font 
  103.          Name            =   "Verdana"
  104.          Size            =   8.25
  105.          Charset         =   0
  106.          Weight          =   700
  107.          Underline       =   0   'False
  108.          Italic          =   0   'False
  109.          Strikethrough   =   0   'False
  110.       EndProperty
  111.       ForeColor       =   &H00004000&
  112.       Height          =   2775
  113.       Left            =   120
  114.       TabIndex        =   0
  115.       Top             =   120
  116.       Width           =   9615
  117.       Begin VB.CommandButton Command2 
  118.          Caption         =   "Close"
  119.          BeginProperty Font 
  120.             Name            =   "MS Sans Serif"
  121.             Size            =   8.25
  122.             Charset         =   0
  123.             Weight          =   700
  124.             Underline       =   0   'False
  125.             Italic          =   0   'False
  126.             Strikethrough   =   0   'False
  127.          EndProperty
  128.          Height          =   375
  129.          Left            =   7920
  130.          TabIndex        =   22
  131.          Top             =   2280
  132.          Width           =   975
  133.       End
  134.       Begin VB.TextBox txtQuan 
  135.          Enabled         =   0   'False
  136.          Height          =   285
  137.          Left            =   6240
  138.          TabIndex        =   4
  139.          Top             =   720
  140.          Width           =   735
  141.       End
  142.       Begin VB.CommandButton cmdFind 
  143.          Caption         =   "Update"
  144.          Enabled         =   0   'False
  145.          BeginProperty Font 
  146.             Name            =   "MS Sans Serif"
  147.             Size            =   8.25
  148.             Charset         =   0
  149.             Weight          =   700
  150.             Underline       =   0   'False
  151.             Italic          =   0   'False
  152.             Strikethrough   =   0   'False
  153.          EndProperty
  154.          Height          =   375
  155.          Left            =   7920
  156.          TabIndex        =   19
  157.          Top             =   1680
  158.          Width           =   975
  159.       End
  160.       Begin VB.CommandButton cmdEdit 
  161.          Caption         =   "Edit"
  162.          BeginProperty Font 
  163.             Name            =   "MS Sans Serif"
  164.             Size            =   8.25
  165.             Charset         =   0
  166.             Weight          =   700
  167.             Underline       =   0   'False
  168.             Italic          =   0   'False
  169.             Strikethrough   =   0   'False
  170.          EndProperty
  171.          Height          =   375
  172.          Left            =   7920
  173.          TabIndex        =   18
  174.          Top             =   1200
  175.          Width           =   975
  176.       End
  177.       Begin VB.CommandButton cmdAdd 
  178.          Caption         =   "Add"
  179.          BeginProperty Font 
  180.             Name            =   "Verdana"
  181.             Size            =   8.25
  182.             Charset         =   0
  183.             Weight          =   700
  184.             Underline       =   0   'False
  185.             Italic          =   0   'False
  186.             Strikethrough   =   0   'False
  187.          EndProperty
  188.          Height          =   375
  189.          Left            =   7920
  190.          TabIndex        =   15
  191.          Top             =   240
  192.          Width           =   975
  193.       End
  194.       Begin VB.TextBox txtGen 
  195.          Enabled         =   0   'False
  196.          Height          =   285
  197.          Left            =   1920
  198.          TabIndex        =   1
  199.          Top             =   720
  200.          Width           =   2895
  201.       End
  202.       Begin VB.CommandButton Command1 
  203.          Caption         =   "Save"
  204.          Enabled         =   0   'False
  205.          BeginProperty Font 
  206.             Name            =   "Verdana"
  207.             Size            =   8.25
  208.             Charset         =   0
  209.             Weight          =   700
  210.             Underline       =   0   'False
  211.             Italic          =   0   'False
  212.             Strikethrough   =   0   'False
  213.          EndProperty
  214.          Height          =   375
  215.          Left            =   7920
  216.          TabIndex        =   14
  217.          Top             =   720
  218.          Width           =   975
  219.       End
  220.       Begin MSComCtl2.DTPicker DTPicker1 
  221.          Height          =   375
  222.          Left            =   6240
  223.          TabIndex        =   13
  224.          Top             =   1080
  225.          Width           =   1455
  226.          _ExtentX        =   2566
  227.          _ExtentY        =   661
  228.          _Version        =   393216
  229.          Enabled         =   0   'False
  230.          Format          =   53477377
  231.          CurrentDate     =   39834
  232.       End
  233.       Begin VB.TextBox txtDes 
  234.          Enabled         =   0   'False
  235.          Height          =   765
  236.          Left            =   1920
  237.          MultiLine       =   -1  'True
  238.          ScrollBars      =   2  'Vertical
  239.          TabIndex        =   3
  240.          Top             =   1440
  241.          Width           =   2895
  242.       End
  243.       Begin VB.TextBox txtBra 
  244.          Enabled         =   0   'False
  245.          Height          =   285
  246.          Left            =   1920
  247.          TabIndex        =   2
  248.          Top             =   1080
  249.          Width           =   2895
  250.       End
  251.       Begin VB.TextBox txtCode 
  252.          Enabled         =   0   'False
  253.          BeginProperty Font 
  254.             Name            =   "MS Sans Serif"
  255.             Size            =   8.25
  256.             Charset         =   0
  257.             Weight          =   700
  258.             Underline       =   0   'False
  259.             Italic          =   0   'False
  260.             Strikethrough   =   0   'False
  261.          EndProperty
  262.          Height          =   285
  263.          Left            =   2160
  264.          TabIndex        =   11
  265.          Top             =   1920
  266.          Width           =   375
  267.       End
  268.       Begin VB.Label Label10 
  269.          AutoSize        =   -1  'True
  270.          BackStyle       =   0  'Transparent
  271.          BeginProperty Font 
  272.             Name            =   "MS Sans Serif"
  273.             Size            =   9.75
  274.             Charset         =   0
  275.             Weight          =   700
  276.             Underline       =   0   'False
  277.             Italic          =   0   'False
  278.             Strikethrough   =   0   'False
  279.          EndProperty
  280.          ForeColor       =   &H00004000&
  281.          Height          =   240
  282.          Left            =   1920
  283.          TabIndex        =   24
  284.          Top             =   360
  285.          Width           =   75
  286.       End
  287.       Begin VB.Label Label9 
  288.          AutoSize        =   -1  'True
  289.          BackStyle       =   0  'Transparent
  290.          Caption         =   "Brand Name:"
  291.          BeginProperty Font 
  292.             Name            =   "Verdana"
  293.             Size            =   9
  294.             Charset         =   0
  295.             Weight          =   700
  296.             Underline       =   0   'False
  297.             Italic          =   0   'False
  298.             Strikethrough   =   0   'False
  299.          EndProperty
  300.          ForeColor       =   &H00004000&
  301.          Height          =   210
  302.          Left            =   360
  303.          TabIndex        =   12
  304.          Top             =   1080
  305.          Width           =   1290
  306.       End
  307.       Begin VB.Label Label6 
  308.          AutoSize        =   -1  'True
  309.          BackStyle       =   0  'Transparent
  310.          Caption         =   "."
  311.          Height          =   195
  312.          Left            =   1680
  313.          TabIndex        =   10
  314.          Top             =   3120
  315.          Width           =   45
  316.       End
  317.       Begin VB.Label Label5 
  318.          AutoSize        =   -1  'True
  319.          BackStyle       =   0  'Transparent
  320.          Caption         =   "Expiration:"
  321.          BeginProperty Font 
  322.             Name            =   "Verdana"
  323.             Size            =   9
  324.             Charset         =   0
  325.             Weight          =   700
  326.             Underline       =   0   'False
  327.             Italic          =   0   'False
  328.             Strikethrough   =   0   'False
  329.          EndProperty
  330.          ForeColor       =   &H00004000&
  331.          Height          =   210
  332.          Left            =   5040
  333.          TabIndex        =   9
  334.          Top             =   1080
  335.          Width           =   1080
  336.       End
  337.       Begin VB.Label Label4 
  338.          AutoSize        =   -1  'True
  339.          BackStyle       =   0  'Transparent
  340.          Caption         =   "Quantity:"
  341.          BeginProperty Font 
  342.             Name            =   "Verdana"
  343.             Size            =   9
  344.             Charset         =   0
  345.             Weight          =   700
  346.             Underline       =   0   'False
  347.             Italic          =   0   'False
  348.             Strikethrough   =   0   'False
  349.          EndProperty
  350.          ForeColor       =   &H00004000&
  351.          Height          =   210
  352.          Left            =   5160
  353.          TabIndex        =   8
  354.          Top             =   720
  355.          Width           =   930
  356.       End
  357.       Begin VB.Label Label3 
  358.          AutoSize        =   -1  'True
  359.          BackStyle       =   0  'Transparent
  360.          Caption         =   "Generic Name:"
  361.          BeginProperty Font 
  362.             Name            =   "Verdana"
  363.             Size            =   9
  364.             Charset         =   0
  365.             Weight          =   700
  366.             Underline       =   0   'False
  367.             Italic          =   0   'False
  368.             Strikethrough   =   0   'False
  369.          EndProperty
  370.          ForeColor       =   &H00004000&
  371.          Height          =   210
  372.          Left            =   240
  373.          TabIndex        =   7
  374.          Top             =   720
  375.          Width           =   1470
  376.       End
  377.       Begin VB.Label Label2 
  378.          AutoSize        =   -1  'True
  379.          BackStyle       =   0  'Transparent
  380.          Caption         =   "Description:"
  381.          BeginProperty Font 
  382.             Name            =   "Verdana"
  383.             Size            =   9
  384.             Charset         =   0
  385.             Weight          =   700
  386.             Underline       =   0   'False
  387.             Italic          =   0   'False
  388.             Strikethrough   =   0   'False
  389.          EndProperty
  390.          ForeColor       =   &H00004000&
  391.          Height          =   210
  392.          Left            =   480
  393.          TabIndex        =   6
  394.          Top             =   1440
  395.          Width           =   1200
  396.       End
  397.       Begin VB.Label Label1 
  398.          AutoSize        =   -1  'True
  399.          BackStyle       =   0  'Transparent
  400.          Caption         =   "Code:"
  401.          BeginProperty Font 
  402.             Name            =   "Verdana"
  403.             Size            =   9
  404.             Charset         =   0
  405.             Weight          =   700
  406.             Underline       =   0   'False
  407.             Italic          =   0   'False
  408.             Strikethrough   =   0   'False
  409.          EndProperty
  410.          ForeColor       =   &H00004000&
  411.          Height          =   210
  412.          Left            =   1200
  413.          TabIndex        =   5
  414.          Top             =   360
  415.          Width           =   570
  416.       End
  417.    End
  418.    Begin VB.Label Label8 
  419.       AutoSize        =   -1  'True
  420.       BackStyle       =   0  'Transparent
  421.       Caption         =   "Label8"
  422.       BeginProperty Font 
  423.          Name            =   "MS Sans Serif"
  424.          Size            =   9.75
  425.          Charset         =   0
  426.          Weight          =   700
  427.          Underline       =   0   'False
  428.          Italic          =   0   'False
  429.          Strikethrough   =   0   'False
  430.       EndProperty
  431.       ForeColor       =   &H00004000&
  432.       Height          =   240
  433.       Left            =   1680
  434.       TabIndex        =   17
  435.       Top             =   5880
  436.       Width           =   735
  437.    End
  438.    Begin VB.Label Label7 
  439.       AutoSize        =   -1  'True
  440.       BackStyle       =   0  'Transparent
  441.       Caption         =   "Total Records:"
  442.       BeginProperty Font 
  443.          Name            =   "MS Sans Serif"
  444.          Size            =   9.75
  445.          Charset         =   0
  446.          Weight          =   700
  447.          Underline       =   0   'False
  448.          Italic          =   0   'False
  449.          Strikethrough   =   0   'False
  450.       EndProperty
  451.       ForeColor       =   &H00004000&
  452.       Height          =   240
  453.       Left            =   120
  454.       TabIndex        =   16
  455.       Top             =   5880
  456.       Width           =   1560
  457.    End
  458. End
  459. Attribute VB_Name = "Form7"
  460. Attribute VB_GlobalNameSpace = False
  461. Attribute VB_Creatable = False
  462. Attribute VB_PredeclaredId = True
  463. Attribute VB_Exposed = False
  464. Option Explicit
  465. Private id As Integer
  466.  
  467. Function ProperCase(ByVal txt As String) As String
  468. Dim utot As Long
  469. Dim need_cap As Boolean
  470. Dim ipot As Integer
  471. Dim charing As String
  472.  
  473.     txt = LCase(txt)
  474.     utot = Len(txt)
  475.     need_cap = True
  476.     For ipot = 1 To utot
  477.         charing = Mid$(txt, ipot, 1)
  478.         If charing >= "a" And charing <= "z" Then
  479.             If need_cap Then
  480.                 Mid$(txt, ipot, 1) = UCase$(charing)
  481.                 need_cap = False
  482.             End If
  483.         Else
  484.             need_cap = True
  485.         End If
  486.     Next ipot
  487.     ProperCase = txt
  488. End Function
  489. Private Sub cmdAdd_Click()
  490. 'txtCode.Enabled = True
  491. cmdEdit.Enabled = False
  492. Command1.Enabled = True
  493. txtGen.Enabled = True
  494. txtBra.Enabled = True
  495. txtDes.Enabled = True
  496. txtQuan.Enabled = True
  497. DTPicker1.Enabled = True
  498. txtGen.SetFocus
  499. End Sub
  500.  
  501. Private Sub cmdLeft_Click()
  502. Dim i As Integer
  503. i = MSFlexGrid1.Index
  504. If i < MSFlexGrid1.Index - 1 Then
  505. i = i + 1
  506. MSFlexGrid1.TabIndex = i
  507. End If
  508. End Sub
  509.  
  510. Private Sub cmdRight_Click()
  511. Dim i As Integer
  512. i = List1.ListIndex
  513. If i > 0 Then
  514. i = i - 1
  515. List1.ListIndex = i
  516. End If
  517. End Sub
  518.  
  519. Private Sub cmdEdit_Click()
  520. cmdEdit.Enabled = False
  521. cmdAdd.Enabled = False
  522. cmdFind.Enabled = True
  523. txtGen.Enabled = True
  524. txtBra.Enabled = True
  525. txtDes.Enabled = True
  526. txtQuan.Enabled = True
  527. DTPicker1.Enabled = True
  528. txtGen.SetFocus
  529. MSFlexGrid1.Enabled = True
  530. End Sub
  531.  
  532. Private Sub cmdFind_Click()
  533. With Data1.Recordset
  534. .Edit
  535. .Fields("Ref_Med") = txtCode.Text
  536. .Fields("Generic_Name") = ProperCase(txtGen.Text)
  537. .Fields("Brand_Name") = ProperCase(txtBra.Text)
  538. .Fields("Description") = ProperCase(txtDes.Text)
  539. .Fields("Quantity") = ProperCase(txtQuan.Text)
  540. .Fields("Expiration") = DTPicker1
  541. .Fields("Date_Entry") = Date
  542. .Update
  543. MsgBox "Has Been Updated"
  544. Unload Me
  545. Me.Show
  546. End With
  547. End Sub
  548.  
  549. Private Sub Command1_Click()
  550. On Error Resume Next
  551. Data2.RecordSource = "Select * from GenericName where Generic = '" & txtGen.Text & "'"
  552. Data2.Refresh
  553. With Data2.Recordset
  554. If txtGen.Text = "" Or txtBra.Text = "" Then
  555. MsgBox "Pls Fill All Information"
  556. Else
  557. Text1.Text = .Fields("Generic")
  558. .AddNew
  559. .Fields("Generic") = ProperCase(txtGen.Text)
  560. .Update
  561. End If
  562. End With
  563.  
  564. With Data1.Recordset
  565. If txtGen.Text = "" Or txtBra.Text = "" Then
  566. MsgBox "Pls Fill All Information"
  567. Else
  568. .AddNew
  569. .Fields("Ref_Med") = txtCode.Text
  570. .Fields("Generic_Name") = ProperCase(txtGen.Text)
  571. .Fields("Brand_Name") = ProperCase(txtBra.Text)
  572. .Fields("Description") = ProperCase(txtDes.Text)
  573. .Fields("Quantity") = ProperCase(txtQuan.Text)
  574. .Fields("Expiration") = DTPicker1
  575. .Fields("Date_Entry") = Date
  576. .Update
  577. MsgBox ("Has Been Save")
  578. Unload Me
  579. Me.Show
  580. End If
  581. End With
  582. End Sub
  583.  
  584. Private Sub Command2_Click()
  585. Unload Me
  586. Main.Show
  587. Main.Enabled = True
  588. End Sub
  589.  
  590. Private Sub form_activate()
  591. Data1.RecordSource = "Select * From stock"
  592. With Data1.Recordset
  593. Do Until Data1.Recordset.EOF
  594. 'MSFlexGrid1.AddItem "    " & Data1.Recordset.Fields("Ref_Med") & ""
  595. Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2
  596. MSFlexGrid1.FormatString = "ITEM CODE    |    GENERIC NAME   |   BRAND NAME   |   DESCRIPTION   |   QUANTITY  |   EXPIRATION   |   DATE ENTRY   "
  597. Data1.Recordset.MoveNext
  598. Loop
  599. Label8 = Data1.Recordset.RecordCount
  600. Label10 = txtCode.Text
  601. End With
  602. End Sub
  603. Private Sub Form_Load()
  604.  
  605. Data1.DatabaseName = App.Path & "\Database\Database.mdb"
  606. Data1.RecordSource = "stockin"
  607. Data1.Connect = ";pwd=nujAwlJa"
  608. Data1.Refresh
  609.  
  610. Data2.DatabaseName = App.Path & "\Database\Database.mdb"
  611. Data2.RecordSource = "GenericName"
  612. Data2.Connect = ";pwd=nujAwlJa"
  613. Data2.Refresh
  614.  
  615.  
  616. Data1.Recordset.MoveLast
  617. id = Data1.Recordset.Fields("Ref_Med") + 1
  618. txtCode.Text = id
  619.  
  620. With ListView1
  621. .ColumnHeaders.Add(, , "Item Code").Tag = "STRING"
  622. .ColumnHeaders.Add(, , "Generic NAme").Tag = "STRING"
  623. .ColumnHeaders.Add(, , "Item Code").Tag = "STRING"
  624. End With
  625. End Sub
  626.  
  627. Private Sub MSFlexGrid1_Click()
  628. Data1.RecordSource = "Select * from Stockin"
  629. Data1.Refresh
  630. With Data1.Recordset
  631. txtCode.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.RowSel, 0)
  632. txtGen.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.RowSel, 1)
  633. txtBra.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.RowSel, 2)
  634. txtDes.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.RowSel, 3)
  635. txtQuan.Text = MSFlexGrid1.TextMatrix(MSFlexGrid1.RowSel, 4)
  636. End With
  637. End Sub
  638.  
  639. Private Sub Text1_KeyPress(KeyAscii As Integer)
  640. If txtQuan.Text = "l" Then
  641. Unload Form7
  642. End If
  643. End Sub
  644.  
  645. End Sub
  646.  
  647. Private Sub txtBra_KeyPress(KeyAscii As Integer)
  648. Select Case KeyAscii
  649.    'Case 48 To 57, 8  ' A-Z, 0-9 and backspace
  650.    'Let these key codes pass through
  651.    Case 65 To 90, 97 To 122, 32, 8, 127 'a-z and backspace
  652.    'Let these key codes pass through
  653.    Case Else 'All others get trapped
  654.    MsgBox "Can not accept a Number", vbOKOnly, "warning"
  655.    KeyAscii = 0 ' set ascii 0 to trap others input
  656.    End Select
  657. End Sub
  658.  
  659. Private Sub txtDes_KeyPress(KeyAscii As Integer)
  660. Select Case KeyAscii
  661.    'Case 48 To 57, 8  ' A-Z, 0-9 and backspace
  662.    'Let these key codes pass through
  663.    Case 65 To 90, 97 To 122, 32, 8, 127 'a-z and backspace
  664.    'Let these key codes pass through
  665.    Case Else 'All others get trapped
  666.    MsgBox "Can not accept a Number", vbOKOnly, "warning"
  667.    KeyAscii = 0 ' set ascii 0 to trap others input
  668.    End Select
  669. End Sub
  670.  
  671. Private Sub txtGen_KeyPress(KeyAscii As Integer)
  672. Select Case KeyAscii
  673.    'Case 48 To 57, 8  ' A-Z, 0-9 and backspace
  674.    'Let these key codes pass through
  675.    Case 65 To 90, 97 To 122, 32, 8, 127 'a-z and backspace
  676.    'Let these key codes pass through
  677.    Case Else 'All others get trapped
  678.    MsgBox "Can not accept a Number", vbOKOnly, "warning"
  679.    KeyAscii = 0 ' set ascii 0 to trap others input
  680.    End Select
  681. End Sub
  682.  
  683. Private Sub txtQuan_KeyPress(KeyAscii As Integer)
  684. Select Case KeyAscii
  685.     
  686.    Case 48 To 57, 8  ' A-Z, 0-9 and backspace
  687.    'Let these key codes pass through
  688.    'Case 65 To 90, 97 To 122 'a-z and backspace
  689.    'Let these key codes pass through
  690.    Case Else 'All others get trapped
  691.    MsgBox "Can not accept a letter", vbOKOnly, "warning"
  692.    KeyAscii = 0 ' set ascii 0 to trap others input
  693.    End Select
  694. End Sub
  695.