Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to use the up down arrow keys to move to next record

Status
Not open for further replies.

Jayz

ISP
Feb 17, 2002
59
Hi,
I have a continuous form, and at the moment using the up down arrow keys only moves to the next field on the record.
Is there a code that will allow these 2 keys to move to the next or previous record instead.

Thanks in advance,
jay
 
That is not a good idea.

You could program all the light switches in your house to start playing the 7th symphony of beethoven (without providing any light), granted that's user specific but what about the light?

If you want a possibility to jump to the next record at any time, either leave the default control buttons that are designed to do just that (like light switches normally turn on the lights), or create a button with a macro DoCmd.GoToRecord.Next on click event if you don't want to show the default configuration that allows for previous/next/first/last record.

 
jay,
Two possibilities here,
One, try the Application.SetOption "ArrowKeyBehaviour" (I forgot the value for NextRecord, try 0, 1, 2 etc.)

Or...

Private Sub SomeField_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next 'Ignore the "Can't go to record" error, just let user figure it out.

If KeyCode = 40 Then 'down arrow
DoCmd.GoToRecord acActiveDataObject, , acNext
ElseIf KeyCode = 38 Then 'Up arrow
DoCmd.GoToRecord acActiveDataObject, , acPrevious
End If

End Sub

If you have many, many fields, and you want to Generate this code, do this:
***** NOTE--this is a good timesaver for all sorts of code
***** This generates an EventProc for all selected controls on form
***** When done, Copy from the Debug window and paste into the form module

Dim f As Form, i As Integer, c As Control
'open the form, it can be in design view if you want
DoCmd.OpenForm "frmyardageEntry" 'Put your form name here
Set f = Forms!frmYardageEntry
For Each c In f
If TypeOf c Is TextBox Or TypeOf c Is ComboBox Then
If c.Section = 0 Then 'if detail
Debug.Print "Private Sub " & c.Name & "_KeyDown(KeyCode As Integer, Shift As Integer)"
Debug.Print "On Error Resume Next "
Debug.Print "If KeyCode = 40 Then 'down arrow"
Debug.Print " DoCmd.GoToRecord acActivedataobject, , acNext"
Debug.Print "ElseIf KeyCode = 38 Then 'Up arrow"
Debug.Print " DoCmd.GoToRecord acActivedataobject, , acPrevious"
'Debug.Print "Else"
Debug.Print "End if"
Debug.Print "End Sub "
'Debug.Print " "
End If
End If
Next c

--Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top