vanquangdy
Thành viên chính thức
- Tham gia
- 29/10/08
- Bài viết
- 65
- Được thích
- 4
mình có Code lưu dữ liệu và thông báo lỗi , nhưng khi viết thấy nó dài quá. Nay mình gửi lên diễn đàn nhờ các bạn rút gọn lại dùm nhé. Cám ơn nhiều
Private Sub CmdLuu_Click()
On Error Resume Next
If txtSoPhieu = "" Then
Msgbox "Ban chua chon so phieu"
Else
If TxtHoten = "" Then
Msgbox "Ban chua dien Ho & ten benh nhân"
Else
If Cbdiachi = "" Then
Msgbox "Ban chua chon dia chi"
Else
If Cbkhoa = "" Then
Msgbox "Ban chua chon khoa dieu tri"
Else
If Cbnoidung = "" Then
Msgbox "Ban chua chon Noi dung thu - chi"
Else
If txtSoTien = "" Then
Msgbox "Ban chua dien So tien"
Exit Sub
Else
If oPT = True And Left(txtSoPhieu, 2) = "PT" Then
Sheet3.[A65536].End(xlUp).Offset(1) = txtSoPhieu
Else
If oPC = True And Left(txtSoPhieu, 2) = "PT" Then
Sheet3.[A65536].End(xlUp).Offset(1) = txtSoPhieu
oPT = True
Else
Sheet3.[B65536].End(xlUp).Offset(1) = txtSoPhieu
oPC = True
CmdLuu.Enabled = False: CmdTaoPhieu.Enabled = True
'Them mot so cau lenh can thiet cua ban
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
Private Sub CmdLuu_Click()
On Error Resume Next
If txtSoPhieu = "" Then
Msgbox "Ban chua chon so phieu"
Else
If TxtHoten = "" Then
Msgbox "Ban chua dien Ho & ten benh nhân"
Else
If Cbdiachi = "" Then
Msgbox "Ban chua chon dia chi"
Else
If Cbkhoa = "" Then
Msgbox "Ban chua chon khoa dieu tri"
Else
If Cbnoidung = "" Then
Msgbox "Ban chua chon Noi dung thu - chi"
Else
If txtSoTien = "" Then
Msgbox "Ban chua dien So tien"
Exit Sub
Else
If oPT = True And Left(txtSoPhieu, 2) = "PT" Then
Sheet3.[A65536].End(xlUp).Offset(1) = txtSoPhieu
Else
If oPC = True And Left(txtSoPhieu, 2) = "PT" Then
Sheet3.[A65536].End(xlUp).Offset(1) = txtSoPhieu
oPT = True
Else
Sheet3.[B65536].End(xlUp).Offset(1) = txtSoPhieu
oPC = True
CmdLuu.Enabled = False: CmdTaoPhieu.Enabled = True
'Them mot so cau lenh can thiet cua ban
End If
End If
End If
End If
End If
End If
End If
End If
End Sub