ADD RECORD
If Command1.Caption = "Add Complaint" Then
Data2.Recordset.AddNew
Picture1.Visible = False
Command1.Caption = "Save"
Command2.Enabled = True
Command3.Caption = "Cancel"
show_forms
Label3.Caption = X
time.Caption = Y
ElseIf Command1.Caption = "Save" Then
Data2.Recordset.Update
hide_forms
Picture1.Visible = True
Command1.Caption = "Add Complaint"
Command2.Enabled = False
Command3.Caption = "Back to Menu"
End If


UPDATE
edit.Enabled = True
Data1.Refresh
Do While Not Data1.Recordset.EOF = True
    If Data1.Recordset("LName") = lsearch Then
        found = True
        Exit Do
    Else
        Data1.Recordset.MoveNext
        found = False
    End If
Loop
If found = True Then
    MsgBox "Record Found!", vbInformation, "MATCH FOUND"
    fname = Data1.Recordset("FName")
    mname = Data1.Recordset("MName")
    lname = Data1.Recordset("LName")
    age = Data1.Recordset("Age")
    contactno = Data1.Recordset("ContactNo")
    sex = Data1.Recordset("Sex")
    compid = Data1.Recordset("CompID")
Else
    MsgBox "Record Not Found!", vbExclamation, "NO MATCH FOUND"
    lsearch.SelStart = 0
    lsearch.SelLength = Len(lname.Text)
    lsearch.SetFocus
End If
lsearch.Text = ""
Command4.Enabled = True
End Sub

DELETE
Data1.Recordset.Delete
MsgBox "Record Deleted", vbExclamation, "Process"
fname.Text = ""
mname.Text = ""
lname.Text = ""
age.Text = ""
contactno.Text = ""
sex.Text = ""
compid.Text = ""
Picture1.Visible = True
Command4.Enabled = False
End Sub


Private Sub edit_Click()
If edit.Caption = "Edit" Then
    edit.Caption = "Save"
    Data1.Recordset.edit
    Data1.Recordset("FName") = fname.Text
    Data1.Recordset("MName") = mname.Text
    Data1.Recordset("LName") = lname.Text
    Data1.Recordset("Age") = age.Text
    Data1.Recordset("ContactNo") = contactno.Text
    Data1.Recordset("Sex") = sex.Text
Else
MsgBox "Update Complete"
    Data1.Recordset("FName") = fname.Text
    Data1.Recordset("MName") = mname.Text
    Data1.Recordset("LName") = lname.Text
    Data1.Recordset("Age") = age.Text
    Data1.Recordset("ContactNo") = contactno.Text
    Data1.Recordset("Sex") = sex.Text
    Data1.Recordset.Update
fname.Text = ""
mname.Text = ""
lname.Text = ""
age.Text = ""
contactno.Text = ""
sex.Text = ""
compid.Text = ""
edit.Caption = "Edit"

0 comments:

Post a Comment