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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

enter key behaviour 1

Status
Not open for further replies.

techkenny1

Technical User
Jan 23, 2009
182
AU
Hi all,
In the options in access I set the enter key set so that the enter key will tab to the next field.
On one form I want the enter key to tab down instead of horizonally when pressed.
Is this possible without having to change settings

Many thanks
 
How are ya techkenny1 . . .

Yes its possible! ... and if you don't mind ... I added the [blue]down key[/blue] as well!.Just perform the following:
[ol][li]Open the form in [blue]design view[/blue]. Call up the properties window and select the form. Then select the [blue]events[/blue] tab.[/li]
[li]Set the [blue]Key preview[/blue] event to [blue]Yes[/blue].[/li]
[li]Next ... in the [blue]On Key Down[/blue] event, copy/paste the following:
Code:
[blue]   Dim hldFieldName As String
   
   If ((Shift = 0) And (KeyCode = vbKeyReturn)) Or _
      ((Shift = 0) And (KeyCode = vbKeyDown)) Then
      hldFieldName = Screen.ActiveControl.Name
      
      If Me.CurrentRecord = Me.Recordset.RecordCount Then
         DoCmd.RunCommand acCmdRecordsGoToNew
         Me(hldFieldName).SetFocus
      ElseIf Me.CurrentRecord > Me.Recordset.RecordCount Then
         KeyCode = 0
      Else
         Me.Recordset.MoveNext
      End If
   End If[/blue]
[/li]
[li]Perform your testing! ...[/li][/ol]
[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
To the Aceman1
Many thanks for this code.
It works exactly as I needed it to.
Regards
Ken
 
I'm a beginner and don't know code. But I'm good at following directions!

I want the enter key to go back to the beginning of the form whenever it is hit so that I can enter a new id number to pull up a new record.

Is that possible? If so, how?

Thanks!
 
How are ya komita . . .

Start a new thread ... so [blue]all[/blue] may benefit from resolution!

I'll be keeping an eye out!

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top