Để con trỏ tự nhảy sang control mới khi nhập liệu xong trong Access?
Đáp: Bạn thử đoạn mã này xem, trong đó: txtNgay là tên ô nhập ngày: Private Sub txtNgay_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode >= 65 And KeyCode <= 90 Then MsgBox "Chi duoc go so" SendKeys "{BACKSPACE}" Exit Sub End If If KeyCode = 9 Then ' Phim TAB ...
Đáp:
Bạn thử đoạn mã này xem, trong đó: txtNgay là tên ô nhập ngày:
Private Sub txtNgay_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode >= 65 And KeyCode <= 90 Then
MsgBox "Chi duoc go so"
SendKeys "{BACKSPACE}"
Exit Sub
End If
If KeyCode = 9 Then ' Phim TAB
Exit Sub
End If
If Len(txtNgay.Text) >= 2 Then
txtNgay.Text = Left(txtNgay.Text, 2) ' Chi nhan 2 ky so
If Val(txtNgay.Text) >= 1 And Val(txtNgay.Text) <= 31 Then
SendKeys "{TAB}"
End If
End If
End Sub
Rồi làm tương tự với ô tháng và năm.