maixuanthu > 06-06-13, 10:44 AM
Trích dẫn:Dim db As Database
Dim rc As Recordset
Dim cm
Dim str
Dim dung As Boolean
If IsNull(Me.magv) = True Then
str = MsgBox ("Ma giao vien khong duoc bo trong!", vbInformation, "Thông Báo")
Exit Sub
End If
dung = False
Set db = CurrentDb()
Set rc = db.OpenRecordset("giaovien")
cm = Me.magv.Value
Do Until rc.EOF
If rc![magv] = cm Then
dung = True
End If
rc.MoveNext
Loop
rc.Close
If dung = True Then
str = MsgBox ("Ma giao vien nay da co nay da ton tai!!Ban co muon thay doi thong tin khong?", vbYesNo + vbInformation, "Thông Báo")
If str = vbYes Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Me.cmdke.Enabled = True
Me.cmdsua.Enabled = True
Me.cmdthem.Enabled = True
Me.cmdthoat.Enabled = True
Me.cmdtruoc.Enabled = True
Me.cmdxoa.Enabled = True
Else
Me.Undo
Me.cmdke.Enabled = True
Me.cmdsua.Enabled = True
Me.cmdthem.Enabled = True
Me.cmdthoat.Enabled = True
Me.cmdtruoc.Enabled = True
Me.cmdxoa.Enabled = True
End If
Exit Sub
End If
If IsNull(Me.magv) = True Or IsNull(Me.hotengv) = True Or IsNull(Me.phaigv) = True Or IsNull(Me.ngaysinhgv) = True Or IsNull(Me.diachigv) = True Or IsNull(Me.sdtgv) = True Or IsNull(Me.tinhtranggv) = True Then
str = MsgBox ("Ban can dien day du thong tin!!", vbInformation, "Thông Báo")
Exit Sub
End If
If IsNull(Me.magv) = False And IsNull(Me.hotengv) = False And IsNull(Me.phaigv) = False And IsNull(Me.ngaysinhgv) = False And IsNull(Me.diachigv) = False And IsNull(Me.sdtgv) = False And IsNull(Me.tinhtranggv) = False And dung = False Then
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
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.cmdsua.Enabled = True
Me.cmdxoa.Enabled = True
Me.cmdthoat.Enabled = True
Exit Sub
End If
Minh Tiên > 17-06-13, 04:53 PM