เหมือนจะง่าย แต่กว่าจะเข้าใจ นำมาฝากครับ วินโดว์ 7 ขึ้นมา ใช้ SendKeys "{HOME}" และ SendKeys "{END}" ไม่ได้แล้ว
Option Compare Database
#If Win64 Or VBA7 Then
Private Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare PtrSafe Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer
#Else
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function GetKeyState Lib "user32.dll" (ByVal nVirtKey As Long) As Integer
#End If
Private Const VK_HOME = &H24
Private Const VK_END = &H23
Private Const VK_F2 = &H71
Private Sub Command2_Click() 'SendKeys HOME
Me.Text0.SetFocus
keybd_event VK_F2, 1, 0, 0
keybd_event VK_F2, 1, KEYEVENTF_KEYUP, 0
keybd_event VK_HOME, 1, 0, 0
keybd_event VK_HOME, 1, KEYEVENTF_KEYUP, 0
End Sub
Private Sub Command3_Click() 'SendKeys END ใช้ F2 แทน
Me.Text0.SetFocus
keybd_event VK_F2, 1, 0, 0
keybd_event VK_F2, 1, KEYEVENTF_KEYUP, 0
End Sub