huuduy.duy > 04-07-13, 09:21 PM
(04-07-13, 12:56 PM)bomnhauag Đã viết: Potay với bạn, để vầy sao mà nó chạy được:Bạn thông cảm nhe, mình đang tự học nên kiến thức Access chưa nhiều, bạn giúp mình nhe
Mã PHP:Private Sub Form_KeyPress(KeyAscii As Integer)
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then ngaybatdau = DateAdd("d", 1, ngaybatdau)
If KeyAscii = 95 Then ngaybatdau = DateAdd("d", -1, ngaybatdau)
End Sub
End Sub
1. Bạn chưa bật thuộc tính Key Preview là Yes cho form mà sao nó chạy được:
2. Chỉnh code lại cho đúng:
Mã PHP:Option Compare Database
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then ngaybatdau = DateAdd("d", 1, ngaybatdau)
If KeyAscii = 95 Then ngaybatdau = DateAdd("d", -1, ngaybatdau)
End Sub
Private Sub ngayketthuc_AfterUpdate()
If IsDate(ngayketthuc) Then NGAYNGHI = DateDiff("d", ngaybatdau, ngayketthuc)
End Sub
Private Sub NGAYNGHI_AfterUpdate()
If Not IsNull(NGAYNGHI) Then ngayketthuc = DateAdd("d", NGAYNGHI, ngaybatdau)
End Sub
3. Chỉnh thuộc tính input mask của 2 textbox: ngaybatdau và ngayketthuc là: 00/00/0000 như trong hình sẽ ok thôi!
Thân!
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then ngaybatdau = DateAdd("d", 1, ngaybatdau)
If KeyAscii = 95 Then ngaybatdau = DateAdd("d", -1, ngaybatdau)
End Sub
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 43 Then ngaybatdau = DateAdd("d", 1, ngaybatdau)
If KeyAscii = 95 Then ngaybatdau = DateAdd("d", -1, ngaybatdau)
If KeyAscii = 43 Then ngayketthuc = DateAdd("d", 1, ngayketthuc)
If KeyAscii = 95 Then ngayketthuc = DateAdd("d", -1, ngayketthuc)
End Sub