Dim str As String Dim ws As workspace Dim db As Database Dim rs As Recordset Dim i As Integer Private Sub addnew_click() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" rs.addnew End Sub Private Sub Command2_Click() End Sub Private Sub Command4_Click() End End Sub Private Sub flx1_Click() Text1.Text = flx1.TextMatrix(flx1.Row, 0) Text2.Text = flx1.TextMatrix(flx1.Row, 1) Text3.Text = flx1.TextMatrix(flx1.Row, 2) Text4.Text = flx1.TextMatrix(flx1.Row, 3) End Sub Private Sub Form_Load() flx1.Formatstring = "sr.no.|^Name|^Age|^Bloofgroup" flx1.Rows = 1 Call connect Set rs = db.OpenRecordset("Select*from BB") flx1.Rows = 1 While Not rs.EOF = True flx1.Rows = flx1.Rows + 1 i = flx1.Rows - 1 flx1.TextMatrix(i, 0) = rs("rs_no") flx1.TextMatrix(i, 1) = rs("Name") flx1.TextMatrix(i, 2) = rs("Age") flx1.TextMatrix(i, 3) = rs("Bl_grp") i = i + 1 rs.MoveNext Wend 'Label1.Visible = False 'Text1.Visible = False End Sub Public Sub connect() Set ws = DBEngine.workspaces(0) Set db = ws.OpenDatabase("C:\VAISHU\BLOOD.mdb") End Sub Private Sub SAVE_Click() rs.addnew rs(1) = Text2.Text rs(2) = Text3.Text rs(3) = Text4.Text rs.UPDATE flx1.Rows = flx1.Rows + 1 If (i > 0) Then flx1.TextMatrix(i, 0) = Text1.Text flx1.TextMatrix(i, 1) = Text2.Text flx1.TextMatrix(i, 2) = Text3.Text flx1.TextMatrix(i, 3) = Text4.Text End If i = i + 1 End Sub Private Sub UPDATE_Click() rs.MoveFirst While Not rs.EOF = True If (rs(0) = flx1.Rows) Then rs.Edit rs(0) = Text1.Text rs(0) = Text2.Text rs(0) = Text3.Text rs(0) = Text4.Text rs.UPDATE MsgBox "record has been updated", vbInformation, "message" Exit Sub Else rs.MoveNext End If flx1.TextMatrix(i, 0) = Text1.Text flx1.TextMatrix(i, 1) = Text2.Text flx1.TextMatrix(i, 2) = Text3.Text flx1.TextMatrix(i, 3) = Text4.Text Wend End Sub