Sunteți pe pagina 1din 2

'For GO Button in searching records

Private Sub cmdgo_Click()


Dim sql
sql = "SELECT * FROM tablename WHERE lname LIKE '%" & txtfind.Text & "%'"
sql = sql & " or itemcode LIKE '%" & txtfind.Text & "%'"
Adodc1.RecordSource = sql
Adodc1.Refresh
dg1.Columns(0).Visible = False
dg1.Columns(1).Caption = "Item Code."
dg1.Columns(1).Width = 1600
dg1.Columns(2).Width = 1800
dg1.Columns(3).Width = 6400
dg1.Columns(2).Caption = "Item Name"
dg1.Columns(3).Caption = "Description"

End Sub
' For save button
Private Sub cmdsave_Click()
txtitemcode.Locked = true
txtitemname.Locked = true
txtdesc.Locked = true
cmdadd.Enabled = True
cmdupdate.Enabled = True
cmdsave.Enabled = False
Adodc1.Recordset.MovePrevious
Adodc1.Recordset.MoveNext

' cmdupdate button


txtitemcode.Locked = false
txtitemname.Locked = false
txtdesc.Locked = false
cmdadd.Enabled = false
cmdupdate.Enabled = false
cmdsave.Enabled = true
Adodc1.Recordset.MovePrevious
Adodc1.Recordset.MoveNext

' to load picture in image object


If Dir("C:\EEC\Img\" & txtitemcode.Text & ".jpeg") <> "" Then
imgitem.Picture = LoadPicture("C:\EEC\Img\" & txtitemcode.Text & ".jpeg")
ElseIf Dir("C:\EEC\Img\" & txtitemcode.Text & ".jpg") <> "" Then
imgitem.Picture = LoadPicture("C:\EEC\Img\" & txtitemcode.Text & ".jpg")
Else
imgitem.Picture = LoadPicture("C:\EEC\Img\default.jpg")
End If

'For adding records

Private Sub cmdadd_Click()


If txtitemcode.Text = "" Or txtitemname.Text = "" Or txtdesc.Text = "" " Then
MsgBox "Please Fill up (*) Required Values", vbOKOnly, "Verification"
Else

Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("itemcode") = txtstudno.Text
Adodc1.Recordset.Fields("itemname") = txtlname.Text
Adodc1.Recordset.Fields("desc") = txtfname.Text
End If

mineeeeeeeeeeeeeeeeeeeeeeeeeeee

If TextCode.Text = """ Or TextName.Text = "" Or Combo1.Text = "" Or TextDesc.Text =


"" " Then
MsgBox "Please Fill up (*) Required Values", vbOKOnly, "Verification"
Else

Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("Item Code") = TextCode.Text
Adodc1.Recordset.Fields("Item Name") = TextName.Text
Adodc1.Recordset.Fields("Catergory") = Combo1.Text
Adodc1.Recordset.Fields("Description") = TextDesc.Text
Adodc1.Recordset.AddNew
MsgBox "Successfully Added"

End If

new

Dg1.Columns(5).Visible = False
Dg1.Columns(0).Caption = "Item Code."
Dg1.Columns(0).Width = 1600
Dg1.Columns(1).Width = 1800
Dg1.Columns(2).Width = 1800
Dg1.Columns(1).Caption = "Item Name"
Dg1.Columns(4).Caption = "Description"
Dg1.Columns(3).Caption = "Date Added"
Dg1.Columns(2).Caption = "Catergory"
Dg1.Columns(3).Width = 1900
Dg1.Columns(4).Width = 5000
Adogrid.Recordset.AddNew
Adogrid.Recordset.Fields("Icode") = TextCde.Text
Adogrid.Recordset.Fields("Iname") = TextName.Text
Adogrid.Recordset.Fields("Description") = TextDesc.Text
Adogrid.Recordset.Fields("Category") = Combo1.Text
Adogrid.Recordset.Fields("Dpicker") = DTp1.Value
Adogrid.Recordset.Update
clear

S-ar putea să vă placă și