Tab order to sub-form...

sroughley

New member
Local time
Today, 07:03
Joined
Jan 22, 2003
Messages
5
Hey all, I am trying to find a way to tab from a field on a Parent form to a field on its child form. I am trying to do something like:

PHP:
Private Sub FormField1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyTab Then
        Me.frmSubForm.Form!FormField2.SetFocus
    End If
End Sub

But can't get it to work.

Any ideas?

Regards.

Steve.
 
Last edited:
Use the tab property dialog to order the tab properties of the controls so that the subform follows the last form to be filled on the mainform. You then won't need any code to get to it.
 
So you mean the last field on the parent should be, for example, 15 and the first on the sub form would then be 16?

Regards.

Steve.
 
Cheers for the help, but I can't seem to get it to work. All that is happening is the Tabing is cycling through the fields on the parent form and not moving on to the child form. I have set the tab order to go from the parent to the child form, but it just doesn't seem to be doing anything.

Any ideas?

Regards.

Steve.
 
OK, I've searched the web quite thouroughly now, and have found in several places that I need to use the setfocus method on the key down event like so:

PHP:
Private Sub Email_KeyDown(KeyCode As Integer, Shift As Integer)
    Dim mblnTabPressed As Boolean
    mblnTabPressed = (KeyCode = vbKeyTab)
    If mblnTabPressed Then
        Me!frmReqLines.SetFocus
        Me!frmReqLines!PartNo.SetFocus
    End If
End Sub

But this throws the error 'Can't move focus to the control frmReqLines!'.

I'm just getting confused now.

Steve.
 
I don't know why you're having trouble. On my forms it works without any code. It is only dependent on the tab order. Have you removed ALL your code? Tabbing OUT of a subform is more of a problem. You can use shift-tab to get back to the last control on the main form.
 

Users who are viewing this thread

Back
Top Bottom