-
Here's my problem. I have a command button (cmdMoveNext) which is used to move through the recordset. I also have data in a datalist box. I coded in my cmdMoveNext_Click so if there was an error, throw up the error and the number. All is well when the user clicks the command button. But if the user uses the up and down arrows on the keyboard to move through the datalist, I get a run time error. I coded in the datalist_KeyPress, to call the cmdMoveNext_click. It's not working. I tried KeyUp, KeyDown, KeyPress, I dont know what else to try?? It just wont trap the errors using the keyboard strokes. Any Comments, thanks
-
Plz tell me exactly what run-time error you're talking about.
-
Jus use the KeyDown event to detect the arrow key is being press and put your code into a respective case,
Code:
Private Sub cmdMoveNext_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyLeft
'##Left arrow key##
'Put your code here
Case vbKeyRight
'##Right arrow key##
'Put your code here
Case vbKeyUp
'##Up arrow key##
'Put your code here
Case vbKeyDown
'##Down arroy key##
'Put your code here
End Select
End Sub
-
Maybe the focus in on another control, you could capture the keypresses whatever control has the focus if you set keypreview to true on the form, then put the code for keydown on the form.
-
I know what I need to do. When the user clicks the down arrow, i need to run some validation before the cursor moves down in the list? Any idea? I've tried keyPress, Keydown, keyUp, FormKeyPreview set to true?