Link to home
Start Free TrialLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

How tab to 1st field on next sub-form

I have a main form with 2 datasheet sub-forms.  On the 1st sub-form, if the user leaves the first field in a new record empty, when they tab off of it I want the cursor to go to the 2nd sub-forms 1st field.


I have tried these and they don't work:


Private Sub cbo1stForm1stCombobox_LostFocus()

    If IsNull(Me.cbo1stForm1stCombobox) Then
        
'        Forms!frmMainForm!frm2ndSubForm.Form!cbo1stField.SetFocus
   
'        Me.Parent.Form!frm1stSubForm.Form.cbo1stField.SetFocus

'        Me.Parent!frm2ndSubForm.Form.cbo1stField.SetFocus
        
'        Forms!frm2ndSubForm.Form.cbo1stField.SetFocus
        
    End If

End Sub

Open in new window

Avatar of Scott McDaniel (EE MVE )
Scott McDaniel (EE MVE )
Flag of United States of America image

You have to be sure you refer to the Subform Control correctly. From the first Subform:

Me.Parent.SecondSubformCONTROL.Form.NameOfControlOnForm.SetFocus

Be careful with the name of the Subform CONTROL. It's the name of the Control on your parent form, and may or may not be named the same as the form that you're using as a Subform.
ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SteveL13

ASKER

Seems I do have to set focus on the 2nd sub-form first.  Thanks.