Sap xep tim kiem theo chimuc tim
Sap xep tim kiem theo chi muc . Voi bang "dshs", tao chi muc " cs1" gom truong lop theo chieu giam va truong to theo chieu tang.
Tim cac hsinh lop 10A1 to1 se doi thanh to3
Sub tim_chi_muc()
Dim db As DataBase, rec As Recordset, tb As TableDef,id As Index,fd As Field
Dim tlop As String,tenmoi As String
Set db= CurrentDb()
Set tb=db.TableDefs("dshs")
'tao chi muc gom truong lop theo chieu giam va truong lop theo chieu tang
On Error Go To loi
tb.Indexes.Delete "cs1"
Set id=tb.CreatIndex("cs1")
Set fd=id.CreateField("lop")
fd.Attributes =dbDescending
id.Fields.Append fd
id.Fields.Append id.CreateField("to")
tb.Indexes.Append id
'Mo recordset kieu table va sap xep theo chi muc "cs1"
Set rec =db.OpneRecordset("dshs")
rec.Index ="cs1"
'Tim hoc sinh dau tien lop 9A TO1
rec.seek "=" , "9A", "1"
Do Until rec.NoMatch
rec.Edit
rec!TO="3"
rec.Update
'TIEP TUC TIM HOC SINH LOP 9A TO1
rec.Seek "=" , "9A", "1"
Loop
rec.Close
Exit Sub
loi:
Resume Next
End Sub
Bạn đang đọc truyện trên: AzTruyen.Top