Results 1 to 9 of 9
  1. #1
    CharissaBelle is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    81

    How do I make the arrow keys go up and down and move to other records?


    I'm working on a split form where there is also a combobox that I am using with the FindFirst method and Form.Bookmark to jump down in the form to a certain record.

    Once I get to that record, I want to be able to use the up and down arrows on my keyboard to go to the previous or next record in the datasheet view. So, I added code to set focus based on the PONumber that has been selected from cboFilter. Before adding the SetFocus, the record would be highlighted, but the arrows wouldn't do anything. Now, with the SetFocus, the record is highlighted and the arrow keys move around inside that record like left to right. How do I make the arrow keys go up and down and move to other records?

    Code:
    Private Sub cboFilter_AfterUpdate()
    
    Dim rs As DAO.Recordset
        
        Set rs = Me.Recordset.Clone
        rs.FindFirst "[PONumber] =" & Str(Nz(Me![cboFilter], 0))
        If Not rs.EOF Then Me.Bookmark = rs.Bookmark
        
        Forms!frmPurchaseOrder!PONumber.SetFocus
        
    End Sub

  2. #2
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    key behavior is a database option. check the microsoft office button > database options, Or have you ruled that out for some reason?

  3. #3
    CharissaBelle is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    81
    I don't know where the microsoft office button is. I'm running Access 2010.

  4. #4
    CharissaBelle is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    81
    I found the options. The arrow key behavior is set to Next Field. This seems correct.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Does that mean you're OK, or that you're not because you don't want to use the setting that causes a move to the next record via the Enter key?
    If not, you'll probably have to use the KeyDown and/or KeyPress events to move to the next record, trapping for the arrow keys (up and down). Never done it - too much bother for the payback, especially if one can use the Enter key by design.

  6. #6
    CharissaBelle is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    81
    The Enter key doesn't move to the next record because I'm using a combobox with FindFirst to jump to the record in the datasheet. The combobox is in the header, so the Enter key just moves to the next thing in the header which is a button to add a new record. KeyPress sounds like a lot of work, but if that's the only way, I'll do it. Do you know of any good tutorials or something on how to do that?

  7. #7
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    WRT the Enter key, I meant when you're on the datasheet, not in the form header. Setting it to 'move to next record' should do just that - once you're on the datasheet. However, that may only apply where the focus is given to the datasheet by way of mouse click. In your case, I think the problem would be that setting the focus to the field will select the data, then usual keyboard action won't work until the field is deselected. I wasn't able to work that out by setting the selLength to zero but I came up with this:
    Instead of setting the focus in the after update event, use DoCmd.GoToControl "NameOfControl" and arrow key should work then.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    CharissaBelle is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2016
    Posts
    81
    I forgot that just by clicking in the field it would allow the arrow keys. Duh! Thank you for that reminder. That is my solution. I can't believe I over-complicated it that much!

  9. #9
    Micron is online now Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    It's the old 'forest' and 'trees' issue! Glad that's solved for you. Maybe you can mark this as 'solved' and save others from checking in to solve a problem.
    Thanks.

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

Similar Threads

  1. Replies: 1
    Last Post: 06-11-2015, 06:15 AM
  2. Replies: 3
    Last Post: 03-11-2014, 12:12 AM
  3. issues with Enter/Tab/arrow keys clearing fields
    By Kimberly42506 in forum Access
    Replies: 10
    Last Post: 12-16-2011, 03:32 PM
  4. Replies: 1
    Last Post: 08-03-2010, 01:33 PM
  5. How to make use of Function Keys (F1, F2 etc)
    By rommelgenlight in forum Access
    Replies: 1
    Last Post: 05-15-2009, 02:51 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