frmSearch.frm

 VERSION 5.00
Begin VB.Form frmSearch
   BackColor       =   &H8000000E&
   Caption         =   "Student Record"
   ClientHeight    =   7950
   ClientLeft      =   60
   ClientTop       =   375
   ClientWidth     =   6045
   LinkTopic       =   "Form1"
   Moveable        =   0   'False
   ScaleHeight     =   7950
   ScaleWidth      =   6045
   StartUpPosition =   2  'CenterScreen
   Begin VB.CommandButton cmdDelete
      Height          =   615
      Left            =   3000
      Picture         =   "frmSearch.frx":0000
      Style           =   1  'Graphical
      TabIndex        =   30
      Top             =   7080
      Width           =   615
   End
   Begin VB.CommandButton cmdClose
      Cancel          =   -1  'True
      Height          =   615
      Left            =   4920
      Picture         =   "frmSearch.frx":040D
      Style           =   1  'Graphical
      TabIndex        =   28
      Top             =   7080
      Width           =   615
   End
   Begin VB.CommandButton cmdSearch
      Height          =   615
      Index           =   1
      Left            =   3960
      Picture         =   "frmSearch.frx":08A1
      Style           =   1  'Graphical
      TabIndex        =   7
      Top             =   7080
      Width           =   615
   End
   Begin VB.TextBox txtName
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   285
      Left            =   480
      TabIndex        =   5
      Top             =   2760
      Width           =   3375
   End
   Begin VB.OptionButton Option4
      BackColor       =   &H8000000E&
      Caption         =   "Course"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3120
      TabIndex        =   4
      Top             =   1680
      Width           =   1215
   End
   Begin VB.OptionButton Option3
      BackColor       =   &H8000000E&
      Caption         =   "First Name"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   3120
      TabIndex        =   3
      Top             =   1320
      Width           =   1455
   End
   Begin VB.OptionButton Option2
      BackColor       =   &H8000000E&
      Caption         =   "Last Name"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Left            =   720
      TabIndex        =   2
      Top             =   1680
      Width           =   1815
   End
   Begin VB.OptionButton Option1
      BackColor       =   &H8000000E&
      Caption         =   "Student Number"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   720
      TabIndex        =   1
      Top             =   1440
      Width           =   2175
   End
   Begin VB.Label Label1
      Caption         =   "*Press Enter"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000C000&
      Height          =   255
      Index           =   12
      Left            =   4080
      TabIndex        =   32
      Top             =   2760
      Width           =   1215
   End
   Begin VB.Label Label1
      Caption         =   "Delete"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   11
      Left            =   3000
      TabIndex        =   31
      Top             =   7680
      Width           =   615
   End
   Begin VB.Label Label2
      Caption         =   "Cancel"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   1
      Left            =   4920
      TabIndex        =   29
      Top             =   7680
      Width           =   615
   End
   Begin VB.Label Label2
      Caption         =   "New Search"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Index           =   0
      Left            =   3840
      TabIndex        =   27
      Top             =   7680
      Width           =   975
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Search through:"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   255
      Index           =   1
      Left            =   360
      TabIndex        =   26
      Top             =   1080
      Width           =   1695
   End
   Begin VB.Line Line3
      X1              =   120
      X2              =   5640
      Y1              =   6960
      Y2              =   6960
   End
   Begin VB.Label lblCN
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   25
      Top             =   6480
      Width           =   2655
   End
   Begin VB.Label lblAdd
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   2040
      TabIndex        =   24
      Top             =   6000
      Width           =   2655
   End
   Begin VB.Label lblDOB
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   23
      Top             =   5640
      Width           =   2295
   End
   Begin VB.Label lblYear
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   22
      Top             =   5280
      Width           =   1455
   End
   Begin VB.Label lblCourse
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   21
      Top             =   4920
      Width           =   1695
   End
   Begin VB.Label lblMI
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   20
      Top             =   4560
      Width           =   975
   End
   Begin VB.Label lblFN
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   19
      Top             =   4200
      Width           =   2775
   End
   Begin VB.Label lblLN
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   18
      Top             =   3840
      Width           =   2775
   End
   Begin VB.Label lblSN
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   255
      Left            =   2040
      TabIndex        =   17
      Top             =   3480
      Width           =   2775
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Contact Number"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   2
      Left            =   240
      TabIndex        =   16
      Top             =   6480
      Width           =   1695
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Address"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   3
      Left            =   240
      TabIndex        =   15
      Top             =   6000
      Width           =   855
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Date of Birth"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   4
      Left            =   240
      TabIndex        =   14
      Top             =   5640
      Width           =   1335
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Year Level"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   5
      Left            =   240
      TabIndex        =   13
      Top             =   5280
      Width           =   1095
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Course"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   6
      Left            =   240
      TabIndex        =   12
      Top             =   4920
      Width           =   735
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "MI"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   7
      Left            =   240
      TabIndex        =   11
      Top             =   4560
      Width           =   375
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "First Name"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   8
      Left            =   240
      TabIndex        =   10
      Top             =   4200
      Width           =   975
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "LastName"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   9
      Left            =   240
      TabIndex        =   9
      Top             =   3840
      Width           =   1095
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Student Number:"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   9
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00C00000&
      Height          =   255
      Index           =   10
      Left            =   240
      TabIndex        =   8
      Top             =   3480
      Width           =   1695
   End
   Begin VB.Line Line2
      X1              =   240
      X2              =   5520
      Y1              =   3240
      Y2              =   3240
   End
   Begin VB.Label lblName
      BackColor       =   &H8000000E&
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H0000C000&
      Height          =   255
      Left            =   360
      TabIndex        =   6
      Top             =   2400
      Width           =   5415
   End
   Begin VB.Line Line1
      X1              =   120
      X2              =   5520
      Y1              =   960
      Y2              =   960
   End
   Begin VB.Label Label1
      BackColor       =   &H8000000E&
      Caption         =   "Record Search"
      BeginProperty Font
         Name            =   "Tahoma"
         Size            =   15.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   840
      TabIndex        =   0
      Top             =   240
      Width           =   2295
   End
   Begin VB.Image Image1
      Height          =   525
      Left            =   240
      Picture         =   "frmSearch.frx":0DC0
      Top             =   240
      Width           =   540
   End
End
Attribute VB_Name = "frmSearch"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim RS As New ADODB.Recordset
Dim cn As New ADODB.Connection


Private Sub cmdOperations_Click(Index As Integer)
cmdOperations
End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub cmdDelete_Click()
On Error GoTo hell
    With RS
      
        If .RecordCount < 1 Then MsgBox "No record to delete.", vbExclamation: Exit Sub
   

Dim ans As Integer, pos As Integer
        ans = MsgBox("Are you sure you want to delete the selected record?", vbCritical + vbYesNo, "Confirm Record Deletion")
        Screen.MousePointer = vbHourglass
        If ans = vbYes Then
            '-Delete the record
            pos = .AbsolutePosition
            cn.BeginTrans
            .Delete
            .Requery
            cn.CommitTrans
            If pos > .RecordCount Then
                If Not .EOF Or .BOF Then .MoveFirst
            Else
                .AbsolutePosition = pos
            End If
            MsgBox "Record has been successfully deleted.", vbInformation, "Confirm"
        End If
        Screen.MousePointer = vbDefault
    End With

Exit Sub

hell:
    Handler Err
End Sub

Private Sub cmdSearch_Click(Index As Integer)
lblName.Caption = ""
txtName.Text = ""
Erasefield
End Sub

Private Sub Form_Load()
AnimateForm Me, aLoad, aMedium
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Viray.mdb;"
With RS
        .ActiveConnection = cn
        .CursorLocation = adUseClient
        .CursorType = adOpenDynamic
        .LockType = adLockOptimistic
        .Source = "select * from tblViray"
        .Open
End With


End Sub



Private Sub Form_Unload(Cancel As Integer)
AnimateForm Me, aUnload, aMedium
End Sub

Private Sub Option1_Click()
lblName.Caption = "Please enter the Student Number you want to search"
End Sub


Private Sub Option2_Click()
lblName.Caption = "Please enter the Last Name of the Student you want to search"
End Sub

Private Sub Option3_Click()
lblName.Caption = "Please enter the First Name of the Student you want to search"
End Sub

Private Sub Option4_Click()
lblName.Caption = "Please enter the Course of the Student you want to search"
End Sub

Private Sub txtName_Change()
If Option1.Value = True Or Option2.Value = True Or Option3.Value = True Or Option4.Value = True Then
SendKeys "{end}"
txtName.Text = StrConv(txtName.Text, vbProperCase)
End If
End Sub

Private Sub txtName_KeyPress(KeyAscii As Integer)
On Error Resume Next
If Option1.Value = True Then
    If KeyAscii = 13 Then
    Dim s
    On Error Resume Next
    RS.MoveFirst
    s = txtName
    While (Not RS.EOF)
        If s = RS.Fields("SN") Then
        MsgBox "Congrats! Record matched."
        field
        GoTo 10
                Else
        RS.MoveNext
        End If
    Wend
    MsgBox "Sorry, no Record matched. Please check the information you provided."
        Erasefield
10
    txtName.SetFocus
   
   
    End If


ElseIf Option2.Value = True Then
    If KeyAscii = 13 Then
    Dim q
    On Error Resume Next
    RS.MoveFirst
    q = txtName
    While (Not RS.EOF)
        If q = RS.Fields("LN") Then
        MsgBox "Congrats! Record matched."
        field
        GoTo 11
        Else
        RS.MoveNext
        End If
    Wend
    MsgBox "Sorry, no Record matched. Please check the number you provided."
        Erasefield
11
    txtName.SetFocus
   
   
End If

ElseIf Option3.Value = True Then
    If KeyAscii = 13 Then
    Dim k
    On Error Resume Next
    RS.MoveFirst
    k = txtName
    While (Not RS.EOF)
        If k = RS.Fields("FN") Then
        MsgBox "Congrats! Record matched."
        field
            GoTo 12
        Else
        RS.MoveNext
        End If
    Wend
    MsgBox "Sorry, no Record matched. Please check the number you provided."
        Erasefield
12
    txtName.SetFocus
   
    Select Case KeyAscii
    Case 97 To 122
    Case 65 To 90
    Case 32
    Case 8
    Case Else
        KeyAscii = 0
End Select
End If

ElseIf Option4.Value = True Then
    If KeyAscii = 13 Then
    Dim g
    On Error Resume Next
    RS.MoveFirst
    g = txtName
    While (Not RS.EOF)
        If g = RS.Fields("COURSE") Then
        MsgBox "Congrats! Record matched."
        field
            GoTo 13
        Else
        RS.MoveNext
        End If
    Wend
    MsgBox "Sorry, no Record matched. Please check the number you provided."
        Erasefield
13
    txtName.SetFocus
   
    Select Case KeyAscii
    Case 97 To 122
    Case 65 To 90
    Case 32
    Case 8
    Case Else
        KeyAscii = 0
End Select
End If
End If
End Sub

Private Sub field()
        lblSN.Caption = RS.Fields("SN")
        lblLN.Caption = RS.Fields("LN")
        lblFN.Caption = RS.Fields("FN")
        lblMI.Caption = RS.Fields("MI")
        lblCourse.Caption = RS.Fields("COURSE")
        lblYear.Caption = RS.Fields("YEARLEV")
        lblDOB.Caption = RS.Fields("DOB")
        lblAdd.Caption = RS.Fields("ADD")
        lblCN.Caption = RS.Fields("CN")
End Sub

Private Sub Erasefield()
lblSN.Caption = ""
        lblLN.Caption = ""
        lblFN.Caption = ""
        lblMI.Caption = ""
        lblCourse.Caption = ""
        lblYear.Caption = ""
        lblDOB.Caption = ""
        lblAdd.Caption = ""
        lblCN.Caption = ""
End Sub

Project Homepage: