0
votes

I have a form with multiple sub-forms.
I would like to have the following behaviour: pressing the tab key in the last field of the main form or in the last field of a subform the focus moves to the next subform or back to the main form according to the defined Tab order.
To achieve this, all subforms as well as the main form have the Cycle property set to Current page.
All subforms are shown within the main form as Datasheets except one that is shown in Form view. Now I get the behaviour I want only for the main form and for the subforms shown as datasheets but not for the subform shown as Form.

Is this the normal behaviour in access 2003, of is there some other property that I have to change?

Note: if I change the default view of the "misbehaving" form to Datasheet as the others, it also behaves as I want...

What am I doing wrong?
And... if this is the way access 2003 works... what would be the best way to obtain the desired behaviour using vba given that I cannot find an OnTab method?

Edit: While waiting to understand if this can be done setting the right properties in the forms, I acheved the desired behaviour with this code in the first and last fields of the "misbehaving" subform.

'In the last field
Private Sub Posizione_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyTab And Shift = 0) Then
        KeyCode = 0
        Me.Parent!Autore_Subform.SetFocus
    End If
End Sub

'in the first field
Private Sub Stanza_KeyDown(KeyCode As Integer, Shift As Integer)
    If (KeyCode = vbKeyTab And Shift = 1) Then
        KeyCode = 0
        Me.Parent!Pagine.SetFocus
    End If
End Sub
1
In access 2.0 I used an extra control at the end and start of a form (and subform) and have code in the OnEnter event of those controls to direct focus to the correct control. I expect this trick to work in Access2003 as well.rene
Its the standard behaviour because the subform is in form view. Use rene's approach.John Bingham
I have had the same problem and I also solved it using code to setfocus to the correct control at the appropriate time.HK1

1 Answers

0
votes

I was just looking for an answer to the same question, and found this via Google: Ctrl-Tab will move from the last control in the subform to the next control in the main form. I found from experimenting (with Access 2007) that it doesn't matter which control has focus in the subform, Ctrl-Tab will pop you out of the subform to the next control in the main form.