390 pts.
 Set Down Arrow Action In Microsoft Access
Hi, I was wondering if there was a way to set when the down arrow is pressed on a Continuous Form in access that it goes to the next record and not the next field. Any suggestions would be great. Thanks, Dustin

Software/Hardware used:
ASKED: February 26, 2009  7:26 PM
UPDATED: February 11, 2011  4:09 PM

Answer Wiki:
Dustin's original answer was a great start, but didn't handle the first and last records in a form. With a bit of help I got to this: 'Put an accurate record counter right at the start of the form's module, ' after the Option Compare Database and Option Explicit statements Public FormRecCount As Integer 'Update the accurate record counter anytime it might change ' Thanks to Martin Green at http://www.fontstuff.com/mailbag/qaccess04.htm Private Sub Form_Current() Dim rst As Object Set rst = Me.RecordsetClone On Error Resume Next rst.MoveLast On Error GoTo 0 FormRecCount = rst.Recordcount End Sub 'Tell form to check each keystroke as per Dustin's answer Private Sub Form_Load() Me.KeyPreview = True End Sub 'Check each keystroke as per Dustin's answer but only move to previous/next ' if not the first/last record. Cancel keystroke if it is. ' Thanks to westconn1 and coolsid for KeyCode = 0 to cancel ' http://www.vbforums.com/showthread.php?t=543543 Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) On Error Resume Next Select Case KeyCode Case vbKeyDown ' Go to the next record If Me.CurrentRecord = FormRecCount Then KeyCode = 0 Else DoCmd.GoToRecord , , acNext End If Case vbKeyUp ' Go to the previous record If Me.CurrentRecord = 1 Then KeyCode = 0 Else DoCmd.GoToRecord , , acPrevious End If End Select End Sub
Last Wiki Answer Submitted:  February 11, 2011  4:09 pm  by  ENTbedford   60 pts.
All Answer Wiki Contributors:  ENTbedford   60 pts. , RoadDust   390 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Thanks for posting the answer.
Sean

 0 pts.

 

Could you tell me if this code would be the same if you wanted the enter button to go down records and the right arrow to still go across in a form? (say if I replaced “KeyUp” with “Enter”)

cheers
M

 10 pts.