maixuanthu > 16-07-13, 12:28 AM
Private Sub luu()
Dim db As Database
Dim rc As Recordset
Dim cm
Dim str
Dim dung As Boolean
If IsNull(Me.mahv_gt) = True Or IsNull(Me.mahv_dgt) = True Then
str = MsgBox("Ma hoc vien khong duoc bo trong!", vbInformation, "Thông Báo")
Exit Sub
End If
dung = False
Set db = CurrentDb()
Set rc = db.OpenRecordset("gioithieu")
cm = Me.mahv_gt.Value
'cm1 = Me.mahv_dgt.Value
Do Until rc.EOF
If rc![mahv_gt] = cm Then
dung = True
End If
rc.MoveNext
Loop
rc.Close
If dung = True Then
str = MsgBox("Ma hoc vien nay da ton tai!!Ban co muon thay doi thong tin khong?", vbYesNo + vbInformation, "Thông Báo")
If str = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
Me.cmdke.Enabled = True
Me.cmddau.Enabled = True
Me.cmdcuoi.Enabled = True
Me.cmdsua.Enabled = True
Me.cmdthem.Enabled = True
Me.cmdthoat.Enabled = True
Me.cmdtruoc.Enabled = True
Me.cmdxoa.Enabled = True
Me.cmdhuy.Enabled = True
End If
Exit Sub
End If
If IsNull(Me.mahv_gt) = True Or IsNull(Me.mahv_dgt) = True Or IsNull(Me.chietkhau) = True Or IsNull(Me.ghichu) = True Then
str = MsgBox("Ban can dien day du thong tin!!", vbInformation, "Thông Báo")
Exit Sub
End If
If IsNull(Me.mahv_gt) = False And IsNull(Me.mahv_dgt) = False And IsNull(Me.chietkhau) = False And IsNull(Me.ghichu) = False And dung = False Then
DoCmd.RunCommand acCmdSaveRecord
str = MsgBox("Ban da luu thanh cong!", vbInformation, "Thông Báo")
Me.cmdthem.Enabled = True
Me.cmdtruoc.Enabled = True
Me.cmdke.Enabled = True
Me.cmddau.Enabled = True
Me.cmdcuoi.Enabled = True
Me.cmdsua.Enabled = True
Me.cmdxoa.Enabled = True
Me.cmdthoat.Enabled = True
Me.cmdhuy.Enabled = True
Exit Sub
End If
End Sub
Noname > 16-07-13, 10:10 AM
Set rc = db.OpenRecordset("gioithieu")
cm = Me.mahv_gt.Value
cm1 = Me.mahv_dgt.Value
Do Until rc.EOF
If rc![mahv_gt] = cm Then
dung = True
End If
rc.MoveNext
Loop
rc.Close
If dung = True Then
str = MsgBox("Ma hoc vien nay da ton tai!!Ban co muon thay doi thong tin khong?", vbYesNo + vbInformation, "Thông Báo")
Set rc = db.OpenRecordset("gioithieu")
Set rc = db.OpenRecordset("select * from gioithieu where mahv_gt='" & Me.mahv_gt &"'" )
If rc![mahv_gt] = cm Then
maixuanthu > 16-07-13, 12:53 PM
Noname > 16-07-13, 05:22 PM
maixuanthu > 16-07-13, 08:39 PM