Results 1 to 7 of 7
  1. #1
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68

    Pressing the Enter key performs a task...

    While entering data in a subdatasheet, I would like the user to be able to press the "Enter" key and have the certain values from the previous record appear in the new record. For instance, there are four fields in a row and the first three usually won't change these are "Depth", "Length", and "NightsSet". Once the user enter's data in the fourth field "PoundsCaught", I would like Access to move to the new record, copy the values from Depth, Length, and NightsSet into the new record, so then all the user has to do is enter PoundsCaught. I also have a "Day" field that I would like to autoincrement to the next day when "Enter" is pressed.



    The problem is, I don't know where to even start this process. Any suggestions?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Review http://www.access-programmers.co.uk/...hlight=default

    Go straight to the end of the thread.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68
    That is a wonderful piece of code. Now is there any way to move to the next record, but stay in the same field, on pressing the enter key rather than having to tab through the rest of the fields in the datasheet and have the default values for those other fields appear?

  4. #4
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68
    I also got the date to auto increment using AfterUpdate and OnEnter...

    Private Sub Text34_AfterUpdate()
    [LiftDate] = [Forms]![frmCOMMERCIAL2]![Combo9] & "/" & [Text34] & "/" & Right([Forms]![frmCOMMERCIAL2]![Combo11], 2)
    Me![Text34].Tag = Me![Text34].Value + 1
    [Text34] = Null
    End Sub

    Private Sub Text34_Enter()
    If Not Me.NewRecord Then Exit Sub
    If Not (IsNull(Me![Text34].Tag) Or Me![Text34].Tag = "") Then
    Me![Text34].Value = Me![Text34].Tag
    [LiftDate] = [Forms]![frmCOMMERCIAL2]![Combo9] & "/" & [Text34] & "/" & Right([Forms]![frmCOMMERCIAL2]![Combo11], 2)
    Me![Text34].Tag = Me![Text34].Value + 1
    [Text34] = Null
    End If
    End Sub

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Issue is resolved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Fish218 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    68
    Everything except for getting the enter key to move to the same field in a new record with all the other fields updating.

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Not easily I think. Would have to detect the Enter key press. This means code that examines each and every key pressed and if the Enter key code is detected, do the desired action. There is a KeyPress event for forms and controls.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 01-17-2012, 02:43 PM
  2. Simple task but must be fast
    By Colman in forum Programming
    Replies: 4
    Last Post: 09-10-2011, 05:27 AM
  3. Replies: 2
    Last Post: 07-21-2011, 08:57 AM
  4. Please assist on this task. I'm stuck.
    By Playerpawn in forum Access
    Replies: 3
    Last Post: 05-17-2011, 01:31 PM
  5. Testing Task - Forms
    By collwill in forum Access
    Replies: 1
    Last Post: 03-09-2011, 10:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums