Results 1 to 4 of 4
  1. #1
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317

    Tabbing nightmare

    Folks



    I have a main form that contains several subforms, and I'm trying to manipulate navigation round the main form so that when a user tabs away from the last field of the last record in a subform, the focus goes to the next control in the main form (the default setting is for the focus to return to the first field of the first record in the subform).

    I've tried two things:
    Code:
     
    Private Sub LastSubformField_KeyPress(KeyAscii As Integer)
     
        If KeyAscii = 9 Then
     
            If Me.NewRecord = True Then
            Me.Parent!NextMainformControl.SetFocus
            End If
     
        End If
     
    End Sub
    Code:
     
    Private Sub FindDocument_Button_KeyDown(KeyCode As Integer, Shift As Integer)
     
        If KeyCode = vbKeyTab Then
     
            If Me.NewRecord = True Then
            Me.Parent!NextMainformControl.SetFocus
            End If
     
        End If
     
    End Sub
    But the problem is this. The KeyAscii method won't allow the focus to settle on LastSubformField when tabbing on to that field from the previous field – the focus goes straight to NextMainformControl. And the KeyCode method won't allow the focus to settle on NextMainformControl when tabbing on to that field from LastSubformField – the focus goes straight to the next-but-one field.

    How the hell to I get the focus to settle on LastSubformField using the KeyAscii method or on NextMainformControl using the KeyCode method?

    Remster

  2. #2
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    As usual, I think I've found the answer just after posting. I need to add 'KeyCode = 0' after setting the focus to cancel the Tab key's usual behaviour.

  3. #3
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    The nightmare continues! Changing the behaviour of the Tab key didn't achieve everything I needed it to, so I've been trying other things. I've tried setting the On Exit event of the last field in each subform so that the focus is passed to the first field of the next subform. But I've come up with an inexplicable problem. I keep getting run-time error 2110, 'Microsoft Access can't move the focus to the control'. The control in question is a control on my main form that contains one of my subforms. The strangest thing of all is that the error doesn't occur every time I try and tab into it. What could be happening?

  4. #4
    Remster is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Sep 2010
    Posts
    317
    In the end I did something convoluted with unbound text boxes that set the focus where needed from their own On Got Focus events.

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

Similar Threads

  1. Replies: 3
    Last Post: 08-17-2010, 02:49 PM
  2. Tabbing order
    By emccalment in forum Forms
    Replies: 1
    Last Post: 02-18-2010, 10:58 AM
  3. Nightmare- Importing probs...and more
    By UCBFireCenter in forum Import/Export Data
    Replies: 14
    Last Post: 01-05-2010, 07:18 PM
  4. 1 to many nightmare
    By damian_gareau in forum Access
    Replies: 0
    Last Post: 07-11-2007, 12:10 PM
  5. My Access Upsizing Nightmare...Opinions and Thoughts?
    By Jerimiah33 in forum Import/Export Data
    Replies: 0
    Last Post: 01-30-2007, 12:40 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