Đỗ Đức Lộc > 15-05-14, 10:51 AM
Minh Tiên > 15-05-14, 03:05 PM
CurrentDb.Execute "ALTER TABLE TableName ADD COLUMN Xeploai TEXT(100)"
CurrentDb.Execute "UPDATE TableNam SET TableName.Xeploai = IIf([DIEM]<=5,'Yeu', IIf([DIEM]<=7,'Trung binh',IIf([DIEM]<=8,'Kha','Gioi')))"
Đỗ Đức Lộc > 15-05-14, 10:17 PM
Minh Tiên > 19-05-14, 10:49 AM
Function CheckFieldExist(tableName As String, fieldName As String) As Boolean
CheckFieldExist = False
Dim db As DAO.Database
Dim tdf As DAO.TableDef
Dim i As Integer
Set db = CurrentDb
Set tdf = db.TableDefs(tableName)
For i = 0 To tdf.Fields.Count - 1
If fieldName = tdf.Fields(i).Name Then
CheckFieldExist = True
Exit Function
End If
Next
End Function
Private Sub btnThuchien_Click()
If CheckFieldExist("Ketqua", "Xeploai") = False Then 'Kiem tra Field Xeploai trong table Ketqua, neu chua co thi tao Field Xep loai.
CurrentDb.Execute "ALTER TABLE KETQUA ADD COLUMN Xeploai TEXT(100)"
End If
CurrentDb.Execute "UPDATE KETQUA SET KETQUA.Xeploai = IIf([DIEMLAN1]<=5,'Yeu', IIf([DIEMLAN1]<=7,'Trung binh',IIf([DIEMLAN1]<=8,'Kha','Gioi')))"
DoCmd.OpenTable "KETQUA"'Mo table Ketqua ra xem
End Sub
Đỗ Đức Lộc > 21-05-14, 04:41 PM