Private Sub Form_Load()
    'This will work as long as database is kept
    'in same folder as VB application
    
    dta_proj.DatabaseName = App.Path & "\ProjectMgt.mdb"
    dta_proj.RecordSource = "Project"
End Sub

Private Sub cb_add_Click()
    dta_proj.Recordset.AddNew
    txt_budget.Text = ""
    txt_num.SetFocus
End Sub

Private Sub cb_del_Click()
    dta_proj.Recordset.Delete
    dta_proj.Recordset.MoveNext
End Sub

Private Sub cb_exit_Click()
    Unload Me
End Sub

Private Sub cb_reset_Click()
    dta_proj.UpdateControls
End Sub

'Validate event triggered by
'CausesValidation property of control
Private Sub txt_budget_Validate(Cancel As Boolean)
    'Error if budget not entered or
    'budget > 1,000,000 (arbitrary)
    If txt_budget.Text = "" Then
        MsgBox ("Must enter budget amount")
        Cancel = True   'KeepFocus on current control
    ElseIf txt_budget.Text > 1000000 Then
        MsgBox ("Budget amount too big")
        Cancel = True
    End If
End Sub

Private Sub txt_end_LostFocus()
    'Error if end date is before start date
    If txt_end.Text < txt_start.Text Then
        MsgBox ("Incorrect end date")
        txt_end.SetFocus
    End If
End Sub

Private Sub txt_findTitle_LostFocus()
    Dim content
    'Build search string;
    'append * to the end in order to use
    'the "like" operator;
    'user only has to enter first characters
    content = Trim(txt_findTitle.Text) & "*"
    content = "p_title like '" & content & "'"
    'If search string was entered, FindFirst
    'will locate first occurence of it
    If txt_findTitle.Text <> "" Then
        dta_proj.Recordset.FindFirst content
    End If
End Sub
